How to remove empty/blank lines from a file in Unix (including spaces)?

This sed line should do the trick:

sed -i '/^$/d' file.txt

The -i means it will edit the file in-place.

Leave a Comment

tech