There are many blank lines after extracting the log files to be viewed recently, which is not conducive to the comparison of previous files. In order to be backward compatible, only empty lines can be deleted when obtained. I googled myself and used the grep method. The efficiency was quite fast. There were 73 blank lines in more than 25000 rows. I should be able to take over the lines in an instant.
Method 1: (I used this)
Grep-V "^ $" file removes matching empty rows
In addition, you can also use grep to view the rows that are empty during troubleshooting, so that you can view the behavior information from the original log file,
Add the parameter-N grep-n "^ $" file to find the empty line and view the information in the original log file.
Method 2: Use the tr command
Cat file name | tr-s '\ N'
Method 3: Use the SED command
Cat file name | sed '/^ $/d'
Method 4: Use the awk command
Cat file name | awk '{if ($0! = "") Print }'
Cat file name | awk '{If (length! = 0) Print $0 }'
Shell removes empty rows