Saturday, November 26, 2011

Using sed to delete lines

This question has already been blogged about plenty. Then answer is something like:

sed '/awk/d' filename.txt

It's just the d command. The blog that this came from is rich with good examples:

http://en.kioskea.net/faq/1451-sed-delete-one-or-more-lines-from-a-file

This other blog recommends using -e with sed in cases like this even when you don't think you need to, because there are many other cases where the quoted command contains "metacharacters". In any case, this blog is full of genius suggestions in general:

http://www.ceri.memphis.edu/computer/docs/unix/sed.htm