Wednesday, March 27, 2013

Delete blank lines with sed

Use this:

sed '/^ *$/d'

Not sure that I understand why this works. ^ is beginning of line, $ is end of line. Why would " *" match only blank lines?

Found here: http://www.unix.com/shell-programming-scripting/22666-delete-blank-lines-sed.html