When configuration files to see linux, in order to facilitate a clear view, will often remove empty rows and rows # head. The linux a lot, grep, sed, awk, tr and other tools can be implemented in a way to delete blank lines. It is summarized as follows:
1、grep
grep - v '^ $' file
2, but
But '/ ^ $ / d' file 或but - n '/./p' file
3、awk
awk '/./ {print}' file 或 awk '{if($0!=" ") print}'
4、tr
tr -s "n"
In addition, vim also when viewing. Command Mode to remove blank lines. vim in command mode Input:
%s/^n//g
Meaning that a global replace all starts with a carriage return character, replace empty. If there are multiple consecutive blank lines, want to keep the line. You only need to enter the following line in the command line mode you can:
%s/^n$//g