Remove empty lines with egrep from a file


egrep -v '^[[:space:]]*$' old.txt > new.txt

or


egrep -v '^\s*$' old.txt > new.txt

-v, –invert-match
Invert the sense of matching, to select non-matching lines.