1833800 Members
2675 Online
110063 Solutions
New Discussion

Re: sed command

 
D Howe
New Member

sed command

I need to delete all lines in a file that DON"T contain the string 'SMSA'. Or alternatively, if I could just select all of the lines that contain 'SMSA' and output them to another file, that would be fine too.

Can anyone help.

Thanks,
Doug.
3 REPLIES 3
Oviwan
Honored Contributor

Re: sed command

Hey

cat yourfilename | grep SMSA > newfile

Regards
Pete Randall
Outstanding Contributor

Re: sed command

From "Handy One-Liners for Sed" (attached)
# print only lines which do NOT match regexp (emulates "grep -v")
sed -n '/regexp/!p' # method 1, corresponds to above
sed '/regexp/d' # method 2, simpler syntax


Pete

Pete
D Howe
New Member

Re: sed command

Thanks guys. Worked great.