From: "David W. Tamkin" <dattier(_at_)ripco(_dot_)com>
sed '/./,/^$/!d'
will reduce all runs of empty line; it will preserve a single empty line at
the bottom if there is one there to start. Some versions of cat have a -s
switch to do that (in other cats, -s does something unrelated), but I don't
recomend that because it will also keep one empty line at the top if there
is no text on the top line of the input.
I used to run my list through
sed -e 's/[ ][ ]*$//' -e '/./,/^$/!d'
to strip trailing whitespace from the right margins and then to squeeze runs
of empty lines. That had the extra benefit of reducing non-empty lines of
nothing but whitespace to emptiness and including them in the squeezing.
[. . . .]
If it is essential to strip all empty lines from the bottom, it gets more
complicated. I figured it out way back in the day but don't remember it
now; it was not just a variation on the code above. Normally, though, one
wants a single empty line at the foot of a message body in email.
I had figured out a pretty nice awk solution for that last one last winter.
I sort of lost it in my beta dir; but I think this is probably it:
gawk '{ ++blank }
NF { while ( --blank ) print ""
print
}'
If that turns out not to be right, shoot me an email, because there are
a couple of other candidates from that effort in the dir. I just think this
was the one, though.
If someone can show me how to do that in sed, I'd find it cool.
--
dman (for no weekly auto-ack, use dman+noacks(_at_)nomotek(_dot_)com)
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail