0

how to remove blank lines in file

In some of the files containing more than 50 lines of code, many blank line appears..... How can i remove those blank lines.....?????

ethan
asked Feb 6, 2017
1 Answer
0

To remove only blank lines in files, either awk or sed command could be used.

awk command helps to display the file without blank lines, whereas sed could be used to modify the source file itself...

For example:

Assume test file contains 50 lines with blank lines.

To view only:

#awk 'NF' test

To modify file:

#sed -i '/^$/d' test
View More
jagannatharumugam
answered Feb 10, 2017
Your Answer
||||
 
100:0