# print 1 line of context before and after regexp, with line number# indicating where the regexp occurred (similar to "grep -A1 -B1")
$ sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h
Delete consecutive blank lines
# 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