procmail
[Top] [All Lists]

Re: How to remove multiple newlines

2004-07-14 19:46:58
Sean's said a lot of the things I wanted to, such as dropping the trailing .* from the condition, but here are some more:

Probably what you're looking for is:

sed -e '/^$/d'

That would remove all blank lines.  Try

sed '/./,/^$/!d'

and be sure to escape the exclamation point if you're using a csh-type shell. It will keep one trailing blank line, but that's a good idea.

:0:
* ^Subject:.*todo
| formail -I "" | sed -e '/^[   ]*$/d' >> $HOME/todo

Wasteful to run formail there as a way to get rid of the head (and yet, to keep the unwanted blank line at the neck); just use the `b' flag to feed only the body to the action:

 :0b:
 * ^Subject:.*todo
 | sed '/./,/$/!d' >> $HOME/todo # \!d if $SHELL is csh or csh-like

I'll take a six-pack of dark beer.  MacTarnahan's Black Watch will do.

Did the OP offer beer? I don't drink, so such things don't stick in my mind.


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail