procmail
[Top] [All Lists]

Re: Removing line-wrapped header

2004-09-10 05:48:20
Toen wij Dallman Ross kietelden, kwam er dit uit:
Ruud:

one sed-call can do it.

Yup, I saved it before when you posted it.  Very nice!  Unfortunately,
you did it too late in the day to spare me a couple of hours of
unplanned screwing around.  :-)  The exercise is still useful
if only as a tutorial (partly to myself).

One could also store the full headers in their original folded state
in a variable first, and work with that.


# is there a cheaper way to isolate the (non-unfolded) header-blob?
  :0w
  { my_HEADERS = `sed '/^$/q'` }


  NL    = "
" SPC   = " "
  TAB   = "     "
  b     = "[$SPC$TAB]"
  S     = "[^$SPC$TAB]"

  my_FIELD = "Received"
  my_REGEX = "by [a-z]+check"

  # Enjoy the way to get rid of the last line
  :0
  *$ my_HEADERS ?? ^^\/(.+$)+$\my_FIELD:.*(^$b.*)*$my_REGEX
  *$ MATCH ?? ^^\/.*(^.*)*^$S.*
  *  MATCH ?? ^^\/(.+$)+.
  *  MATCH ?? ^^\/(.*$)+..+$
  { my_HEAD = "$MATCH" }

  my_TAIL
  :0
  *$ my_HEADERS ??
^$\my_FIELD:.*(^$b.*)*.*$my_REGEX.*(^$b.*)*^\/$S.*(^.*)*^^
  { my_TAIL = "$MATCH" }

  :0 h fw
  | echo "$my_HEAD$my_TAIL$NL"


Nice going, Ruud.

You too. And sed-user Gudermez rules.
http://groups.yahoo.com/group/sed-users/messages/4696
(if you have a yahoogroups-login)

-- 
Grtz, Ruud


____________________________________________________________
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>