Monday, November 12, 2012

Delete lines inside a file matching a pattern

You can use pattern matching of sed to do so !

sed -i '/pattern/d' filename
Example: To remove the lines containing "server" from foo.txt ,do this
sed -i '/server/d' foo.txt

I felt this usefull often . For more SED tutorials , visit http://www.grymoire.com/Unix/Sed.html