Remove empty lines in files

Remove blank lines (not including lines with spaces).
grep . file.txt

Remove completely blank lines (including lines with spaces).
grep “\S” file.txt
or
grep -Ev “^$” file.txt

awk solution:
awk NF file.txt

sed -i ‘/^$/d’ file.txt

It actually needs to be “/^ *$/d” to remove lines that only contain spaces.

”/^\s*$/d”
it would include tabs