#!/usr/bin/sed -nf # delete all blanks /./ !d # get here: so there is a non empty : x # print it p # get next n # got chars? print it again, etc... /./ b x # no, don't have chars: another empty line : z # get next n # also empty? then ignore it, and get next... this will remove ALL empty # lines, if we get to end, sed script will finish on n(ext) command # so no trailing empty lines are written /./ !b z # all empty lines were deleted/ignored, but we have a non empty, as # what we want to do is to squeeze, insert a blank line artificially i \ b x ### colorized by sedsed, a sed script debugger/indenter/tokenizer/HTMLizer ### original script: http://pcsiwa.rett.polimi.it/~paolob/seders/scripts/cat-s.sed