sed -e /^$/d
Ever needed to replace some stuff when using
sed on the command line but had issues with replacing newlines, as well?
Take a scenario like the usage of
mod_dumpio, which writes a lot of lines ending with
bytes to specify the amount of bytes read - if you're after the HTTP requests, this is utterly uninteresting, but has a lot of overhead.
You quickly write a small
's/^.*bytes$//', to get rid of the problem, but the linebreak remains.
sed is very uncooperative regarding linebreaks.
The trick: a seperate expression to replace blank lines:
-e 's/^.*bytes$// -e '/^$/d'`. And there you go, no more blank lines after a whole-line removal.