Remove blank lines using awk.

NF variable in awk holds the number of fields in the line. In case of empty line, NF is zero and the condition is not met, so awk does nothing.

example.txt

1

2

3

4

5

6

7

8

9

ex358.txt

awk 'NF' example.txt

output:

1
2
3
4
5
6
7
8
9

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading