I want to remove all X headers from the email.
The obvious solution, using formail, does not work
:0 fhw
| formail -I X-*:
Hi,
How about:
:0 fhw
| grep -v ^X- | (pipe into whatever you want)
This will not do what you want since the X- header might occupy
more than one line. Procmail combines all the lines into one for
pattern-matching purposes, but does not feed them to filters that way.
You could do this using most any of the *awk programs (maybe not the
old, original "vanilla" awk) but it is a bit awkward (sorry :)
:0 fhw
| gawk 'NF==0 {print;next} \
/^[ ]/ && !s {print;next} \
/^[ ]/ {next} \
/^[Xx]-/ {s=1;next} \
{s=0;print}'
For the curious, that works thusly, line-by-line:
if the line is blank, print it
else if the line starts with whitespace and s is zero, print it
else if the line starts with whitespace, skip it
else if the line starts with "X-" or "x-" then set s to 1, and skip it
else set s to 0, and print it
(s is initially zero; I use it to represent a "skipping this line" state)
But, since (as Philip pointed out) formail does the job nicely, it's
much more straightforward to use formail.
Cheers,
Stan