FILE
:
hello
world
foo
bar
How can I remove all the empty new lines in this FILE
?
Output of command:
If removing empty lines means lines including any spaces, use:
grep '\S' FILE
For example:
$ printf "line1\n\nline2\n \nline3\n\t\nline4\n" > FILE
$ cat -v FILE
line1
line2
line3
line4
$ grep '\S' FILE
line1
line2
line3
line4
$ grep . FILE
line1
line2
line3
line4
See also:
sed
: Delete empty lines using sedawk
: Remove blank lines using awk