How to remove blank lines in .txt files

You can use GNU sed:

sed -i -e "/^$/d" su.txt

Will delete blank lines.


If you're on a BSD variant or OS X, use this instead:

sed -i '' -e "/^$/d" su.txt

Here, -i takes an extension as an argument – using the GNU sed syntax would result in a file su.txt-e being created.