Friday, March 11, 2016

Remove empty line from file using sed

If you want to remove all lines that do not contain any characters from a file use sed to find lines that match regex ^$ and then delete it.

mpjanic@zoran:~/AHR-TCF21$ cat tmp
NPPC

LINC00939

PCSK1N

MIR7974

NT5E

PTMS

mpjanic@zoran:~/AHR-TCF21$ sed -i '/^$/d' tmp
mpjanic@zoran:~/AHR-TCF21$ cat tmp
NPPC
LINC00939
PCSK1N
MIR7974
NT5E
PTMS
mpjanic@zoran:~/AHR-TCF21$

No comments:

Post a Comment