Help with removing line from text

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with removing line from text
# 1  
Old 07-24-2011
Help with removing line from text

Hey everyone, I kinda new to shell programming and learning bits and pieces of stuff from tutorials.

I got this problem, where
I asked my user to enter a string, which will delete a specific line in the string, which I'm unable to do it.

Text file(BookDB.txt) as shown:

Three Little Pig:Andrew Lim:89.10
All About Ubuntu:Ubuntu Team:76.00
Catch Me If You Can:Mary Ann:23.60
Happy Day:Mary Ann:12.99

Lets say I type Catch Me if You Can. It will delete the entire string line. I tried sed but kinda new to it.
This is the code I tried..
cut -d: -f1 BookDB.txt
echo "Enter title to remove"
read title
sed -e '/'$title'/d' BookDB.txt

Am I doing the correct thing?
# 2  
Old 07-24-2011
echo "Enter title to remove"
read title
sed -i "/$title/d" BookDB.txt

Try to search "BookDB.txt" on this forum.
# 3  
Old 07-24-2011
Haha I did try thou it only return my post and yours.
# 4  
Old 07-24-2011
This User Gave Thanks to yazu For This Post:
# 5  
Old 07-24-2011
Thx dude ya awesome!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - help in removing some text

Hey Guys, Earlier I asked a question under Solaris, which I got great help... thanks. Although I got the script working for what it really needed to do, I am looking for a bit of help to change the output for nicer reading. my script gets a list of zones under a global-zone and puts this... (4 Replies)
Discussion started by: dakelly
4 Replies

2. UNIX for Dummies Questions & Answers

Removing \n from a text file

Hi All, I have a question regarding text substitution. I have a file that contains a lot of text. Some of the text is separated with a \n like: TEST\nTEST2\nTEST3 BLA\nBLA2\nBLA3 So there are both actual newlines and 'used to be newlines' in the text. using tr tr "\n" "," or... (5 Replies)
Discussion started by: JaapSchuurman
5 Replies

3. UNIX for Dummies Questions & Answers

Removing PATTERN from txt without removing lines and general text formatting

Hi Everybody! First post! Totally noobie. I'm using the terminal to read a poorly formatted book. The text file contains, in the middle of paragraphs, hyphenation to split words that are supposed to be on multiple pages. It looks ve -- ry much like this. I was hoping to use grep -v " -- "... (5 Replies)
Discussion started by: AxeHandle
5 Replies

4. Shell Programming and Scripting

removing lines without text

How do I remove line that do not contain text, but that do contain tabs? I have tried the command cat file | awk NF but that doesn't work when the lines contain tabs (and spaces). I have also tried: cat file | sed '/^$/d' (9 Replies)
Discussion started by: locoroco
9 Replies

5. Shell Programming and Scripting

Removing a line IF the next line contains string

So, I've been working on a project which takes layer 7 metadata from pcap dumps and archives it. However, there is a lot of dataless information that I don't want in my output. I know of ways to produce the output I want from the input file below, but I want a method of doing this, regardless of... (2 Replies)
Discussion started by: eh3civic
2 Replies

6. Shell Programming and Scripting

Removing matching text

Hello Everyone! Of course I am rather new to these forums, but I have been browsing the forums for awhile, always has a lot of useful information :) This time however, I can not find the information I need, well, not completely. So here is the problem, I am a linux admin (dealing mostly with... (1 Reply)
Discussion started by: Rhije
1 Replies

7. Shell Programming and Scripting

Sed question (Removing a line of text)

I am working with bash on HP-UX server at school. As practice for scripting, I am trying to make a pretend server admin script that adds a user to the system, deletes a user from the system, and lists all users of the pretend system. I have accomplished this with a select loop. Adding users, and... (2 Replies)
Discussion started by: masterscout1977
2 Replies

8. Shell Programming and Scripting

Removing text from a line in a file

Hi All, I would like to know how to remove text from a line in a file. eg to The 4 sets of numbers are not static ie they change on each line in each different file so if anyone can help that would be great. Jeremy (10 Replies)
Discussion started by: outthere_3
10 Replies

9. UNIX for Dummies Questions & Answers

removing line and duplicate line

Hi, I have 3 lines in a text file that is similar to this (as a result of a diff between 2 files): 35,36d34 < DATA.EVENT.EVENT_ID.s = "3661208" < DATA.EVENT.EVENT_ID.s = "3661208" I am trying to get it down to just this: DATA.EVENT.EVENT_ID.s = "3661208" How can I do this?... (11 Replies)
Discussion started by: ocelot
11 Replies

10. Shell Programming and Scripting

Removing a particular line from a text file

Hi, I have a file called inp.txt the contents of the file are as follows MANI123|23|41 MANI123|96|23 I want to reove the first line of this file. How can I do it. Thanks in advance (5 Replies)
Discussion started by: sendhilmani123
5 Replies
Login or Register to Ask a Question