procmail
[Top] [All Lists]

Grepping body of message

2003-04-23 11:52:10
I get a lot of automated announcements that contain a lot of stuff that doesn't concern me, so I wrote this recipe to only let them through if they contain "foo" or "bar" in the body:

:0:
* ^From:(_dot_)*root(_at_)(_dot_)*\(_dot_)domain(_dot_)com
* ^Subject:.*Swatch\ Report.*
{
        :0 B
        * !(foo|bar)
        $TRASH
}
$MAIL

That works fine and eliminates a lot of mail I don't need. However, the individual messages have a lot of text, so I'd like to trim down the messages I do get by grepping for foo|bar in the body of the message and having only that display in the body. The problem is that just piping it through grep will remove my headers, too, which I obviously don't want. I thought maybe I could use formail to grab the headers, then run the message through grep, and re-prepend the captured headers to the truncated body, but that seems difficult and unwieldy (and perhaps impossible). So I wanted to check here first to see if there were better solutions.

--
----------------------------------------------------------------------------
Kim Scarborough                                  http://www.unknown.nu/kim/
----------------------------------------------------------------------------
"Trying is the first step towards failure."
                                                             - Homer Simpson
----------------------------------------------------------------------------
Now listening to: Charlie Christian - "Wholly Cats [No. 2]"
----------------------------------------------------------------------------


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>