The following two gawk programs remove any email header which matches the given regular expression. The header may be wrapped (folded) into multiple lines - this is why a simple grep -v doesn't work. (C) Volker Kuhlmann, 9 Sep 2004 Released under the GNU General Public License. Subject: Removing line-wrapped header: gawk From: Volker Kuhlmann <.....@paradise.net.nz> Date: Thu, 09 Sep 2004 22:48:08 +1200 Sender: procmail-bounces@lists.RWTH-Aachen.DE Both these gawk solutions seem to work. The second is more universal but slightly slower. As shell script because I don't like programs exceeding 1 line in .rc, but can be easily changed. GPL, if anyone cares. Any perl solution suffers from huge overhead, but is more portable. As I don't speak it I tend to avoid it... Thanks for your thoughts everyone. Volker # Remove all headers of the given name whos value matches the given regular # expression. # The header may be folded onto multiple lines. The formatting of headers not # removed is unchanged. # Function arguments: # $1: beginning of header name (e.g. "X-", or "X-List:"; some limited regular # expressions are allowed here) # $2: regular expression to match; expressions as for egrep # Awk portability issues: # * IGNORECASE # * "\n" string literals # * \t in patterns # * ENVIRON array (this nicely deals with quoting issues for $2) rm_header_match() { RE="$2" gawk ' BEGIN { IGNORECASE=1; line=""; RE=ENVIRON["RE"] } /^[ \t]/ && line!="" { line = line "\n" $0; next } line!="" { if (!match(line, RE)) print line; line="" } /^'"$1"'/ { line=$0; next } { print } ' } # Remove all header lines which match the given regular expression. # The header may be folded onto multiple lines. The formatting of headers not # removed is unchanged. # rm_header_match() runs slightly faster, but the header name must be fixed. # Function arguments: # $1: regular expression to match; expressions as for egrep # Awk portability issues: as for rm_header_match() rm_headerline_match() { RE="$1" gawk ' BEGIN { IGNORECASE=1; line=""; RE=ENVIRON["RE"] } /^[ \t]/ && line!="" { line = line "\n" $0; next } line!="" { if (!match(line, RE)) print line; line="" } /^[^ \t]/ { line=$0; next } { print } ' } -- Volker Kuhlmann is possibly list0570 with the domain in header http://volker.dnsalias.net/ Please do not CC list postings to me. ____________________________________________________________ procmail mailing list Procmail homepage: http://www.procmail.org/ procmail@lists.RWTH-Aachen.DE http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail