Posts
read more
Deleting Blank Lines Using Grep
If you have a file (or a stream) that has blank lines you want to remove, you can use this command:
$ grep -v "^ *$" file-with-blanks.txt > output-file.txt
where file-with-blanks.txt is the input file and has blank lines and output-file.txt will
be the output file without the blank lines.
You have to keep the space between the ^ and the *$ otherwise blank lines which include
spaces will not be removed.