procmail
[Top] [All Lists]

Re: Editing text of messages via procmail

2001-11-19 16:37:42
I subscribe to several mailing lists. Most of which, deliver in a digest 
format.
They always have a lot of administrative info before "Today's Topics".
I'd like to create a recipe that would remove all of the Text up to 
"Today's Topics"
from messages that are from list digests.
I would guess that piping the messages through a perl or sed script 
could do this.

Assuming that you recognise digests from the Cat Polishing mailing list
and deliver to your 'shinycat' mailbox with a recipe like:

  :0 :
  * ^List-Id: Cat Polishing
  shinycat

you can trim lines up to and including the first line containing the
text "Today's Topics" using something like:

  :0
  * ^List-Id: Cat Polishing
  {

    # use a filter to strip lines from the body
    :0 fwb
    | sed "1,/Today's Topics/d"

    # deliver the modified mail to the mailbox
    :0 :
    shinycat
  }

The sed script deletes lines (the 'd') from line 1 (the '1') up to the
first line matching the given text (the ',/Today's Topics/').

That's a filter (the 'f' flag on the colon line) and so it modifies the
mail rather than delivers it.  The 'b' means that only the body gets
modified, so the mail headers aren't affected.

Hope that helps,
Martin
-- 
Martin McCarthy                 /</                  PGP key available
    `Procmail Companion'        \>\  http://www.ancient-scotland.co.uk
     Addison Wesley             /</    http://www.ehabitat.demon.co.uk
_______________________________________________
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>