Question: I need to remove empty new lines from text file in terminal.

Example file

```
123
123
123
123

123

123

```

I've searched in google a bit but only solution found was `sed '/^$/d' myFile > tt` and it does not help. I still got these empty new lines.

Answer: 
**Using AWK:** NF is AWK's in-built variable that stores the number of fields in each record. When used by it self, it will print only those lines where NF!=0. 

```
[jaypal~/Temp]$ cat t
123
123
123
123

123

123

[jaypal~/Temp]$ awk 'NF' t
123
123
123
123
123
123

```
Use grep for empty lines:

```
grep . file

```

Or try the [ex](https://en.wikipedia.org/wiki/Ex_(text_editor))-way (cross-platform compatible) for blank lines (e.g. containing whitespaces):

```
ex -s +'v/\S/d' -cwq test.txt

```

For multiple files (edit in-place):

```
ex -s +'bufdo!v/\S/d' -cxa *.txt

```

Note: The `:bufdo` command is not [POSIX](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html).

Without modifying the file (just print on the standard output):

```
cat test.txt | ex -s +'v/\S/d' +%p +q! /dev/stdin

```