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 lines using SED

Status
Not open for further replies.

unixxxx

MIS
Oct 20, 2000
17
US
I have question about sed. If I have a file and I want to delete all lines in the file except the lines that start with the word "HELLO". How should I make a script using sed command? [sig][/sig]
 
Well please post your answer. Some of us would like to know as well. [sig][/sig]
 
Why sed? Why not use grep to extract all the lines with HELLO in it?

cat filename.txt | grep "HELLO" > newfile.txt Mike davison
mike.davison@avon.com
 
errmmmm --- *starting* with 'HELLO' guys...... LOL

grep '^HELLO' filename > outputfile
Mike
michael.j.lacey@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top