procmail
[Top] [All Lists]

Re: Removing line-wrapped header

2004-09-09 04:39:55
On Thu, Sep 09, 2004 at 12:25:13PM +1200, Volker Kuhlmann wrote:

The header name is known, and there will be multiple headers of that
name. I want to remove a particular instance of that header, the one
which has "somestring" in the value part.

Okay, I see others have attacked the problem, including a solution
in perl from Don.  I have another solution, not particularly better,
just different (since I don't know perl) :-).

formail -IHeadername: removes all the headers with that name, but I only
want to remove a single one. formail couldn't even remove the first or
last (only leave the first or last). That's requiring to know that it is
the Nth header I want to axe, which is a requirement I prefer to get
around if possible as I suspect it's unreliable in my case.

NL = "
"
KNOWN_HFIELD = "Received"   # set to what you want
KNOWN_STRING = "pD9E7AB08"  # I used this because it was in one Received
                            # in my test mail; set to what you want

  :0
  * $ ^^\/(.+$)+$\KNOWN_HFIELD:(.*\<)?$\KNOWN_STRING\>
  * MATCH ?? ^^\/(.+$)+.
  * MATCH ?? ^^\/(.*$)+..+$
  { H_TOP = "$MATCH" }

  :0
  * $ ^$\KNOWN_HFIELD:(.*\<)?$\KNOWN_STRING\>.*$\/(.+$)*
  { H_BTM = "$MATCH" }

  :0 h fw
  | echo "$H_TOP$H_BTM" | sed "s/$TAB/\\$NL&/g"

If you didn't care about replacing the line breaks, we could leave out
the sed -- meaning the only external process is one 'echo'.  But then,
if you didn't care, you could use David Tamkin's "formail -c" solution.
Oh, well.

Dallman

____________________________________________________________
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

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