procmail
[Top] [All Lists]

RE: most efficient way to get rid of all headers except 3

2001-12-30 01:01:54


-----Original Message-----
From: procmail-admin(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE
[mailto:procmail-admin(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE]On Behalf Of 
Timothy J.
Luoma
Sent: Saturday, December 29, 2001 6:52 PM
To: Procmail List
Subject: most efficient way to get rid of all headers except 3



In a certain recipe, I would like to get rid of all headers except:

From
Subject
Date

All the headers will exist for all messages.

Does anyone have the most efficient way of doing this?  It
will run on a lot
of messages per week


You might try the following recipe:

:0 fhw
| (formail -X From -X From: -X Subject: -X Date: ; echo "")

The "-X From" is optional, but needed if you want the resulting message
to be well-formed. Likewise the 'echo ""' is needed to ensure that the
header terminates with a blank line.

To test this out, put the following into a file named tst.rc:

DEFAULT=|
LOGFILE=tst.log
LOGABSTRACT=all
VERBOSE=yes

:0 fhw
| (formail -X From -X From: -X Subject: -X Date: ; echo "")

and run the following command:

  procmail ./tst.rc < msg

where "msg" is a file containing a single mail message. The newly
formatted
message will appear on stdout. Optionally, you can use egrep:

:0 fhW
| egrep -i '^(From |From: |Date: | Subject:|$)'

The "W" is used above, because egrep might return a non-zero status if
none of the header fields exist, and we want to ignore the status return
in that case.





_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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