User Tools

Site Tools


sed:delete:delete_all_consecutive_blank_lines_from_file_except_the_first

SED - Delete - Delete all CONSECUTIVE blank lines from file except the first

Also deletes all blank lines from top and end of file (emulates “cat -s”).

sed '/./,/^$/!d'          # method 1, allows 0 blanks at top, 1 at EOF
sed '/^$/N;/\n$/D'        # method 2, allows 1 blank at top, 0 at EOF
sed/delete/delete_all_consecutive_blank_lines_from_file_except_the_first.txt · Last modified: 2020/08/17 10:26 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki