grep -v '^$' oldfile > newfile
^$
is a regular expression that matches an empty line. ^
matches the beginning of the line, $
matches the end of the line, and there's nothing between them. The -v
option to grep
means to print all lines that don't match the regular expression.
To learn about regular expressions, go to regular-expressions.info