I found this question and answer on how to remove triple empty lines. However, I need the same only for double empty lines. Ie. all double blank lines should be deleted completely, but single blank lines should be kept.
I know a bit of sed, but the proposed command for removing triple blank lines is over my head:
sed '1N;N;/^\n\n$/d;P;D'
I’ve commented the
sedcommand you don’t understand:Remove
1Nbecause we need only two lines in the ‘stack’ and it’s enought with the secondN, and change/^\n\n$/d;to/^\n$/d;to delete all two consecutive blank lines.A test:
Content of
infile:Run the
sedcommand:That yields: