On Tue, 22 Sep 2009 13:03:16 +0100 Martin Gregorie <mar...@gregorie.org> wrote:
> gawk ' > BEGIN { act = "copy" } > /^X-Spam/ { act = "skip" } > /^[A-WYZ]/ { act = "copy" } > { > if (act == "copy") > { print } > } > ' There are a few problem with that: 1 - it deletes all consecutive headers starting with an X that follow an X-Spam header e.g. "X-Delivered-to" 2 - if the bottom header is deleted, the header-body separator is also deleted 3 - ^X-Spam can match on the body causing part of it to be deleted, in the worst case corrupting the mime structure. I think the following is a bit more robust: awk ' /^[^[:space:]]/ { remove = 0 } /^X-Spam/ { remove = 1 } /^$/ { isbody = 1 } isbody || !remove { print } '