Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delete one line with bash ?

Status
Not open for further replies.

haneo

Programmer
Jan 2, 2002
274
CA
I want to delete one line containning "my name" for exemple, with a script.

Can some one help me !

Thanks
 
There are alot of ways to do it, shell or perl would be your main bets.

Using a quick grep on the sh:

cat file.txt | grep -v 'my name' > file.txt

Sed has a delete operator as well, so does awk
 
Hi:

Here's an awk solution. The grep method is probably more efficient:

awk ' {
if(index($0, "my name"))
next
else
print $0
} ' data.file > newdata.file

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top