Ruud H.G. van Tol schreef:
Ruud H.G. van Tol schreef:
$ formail +1 -z -cx From: \
-cx Subject: \
-cx Status: \
-s sed -nf abstract.sed < mailbox-file
Better:
formail -a Status: \
-cx From: \
-cx Subject: \
-cx Status: \
-s sed -nf abstract.sed
The output is not always in the right order:
some spam mail arrives with a Status: header on top;
the From: can be after the Subject:.
So this
$ < mailbox-file \
formail -cz \
-RFrom: 1: \
-RSubject: 2: \
-RStatus: 3: \
-a3: -X1: -X2: -X3: -s
can produce this:
1: Mail System Internal Data <MAILER-DAEMON(AT)imap3.xs4all.nl>
2: DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA
3: RO
3: R
1: "Microsoft Security Bulletin" <clambpnctmji(AT)support.msn.com>
2: Last Internet Security Upgrade
3: R
2: Error Advice
1: "Postmaster" <cmailrobot(AT)america.com>
but that is no problem:
$ < mailbox-file \
formail -cz \
-RFrom: 1: \
-RSubject: 2: \
-RStatus: 3: \
-X1: -X2: -X3: -s sed -nf abstract.sed
# Filename: abstract.sed
# ----------------------
# This sed-script should be called with the -n option.
# Append all lines to the pattern space,
# separated by \n.
#
:a
$! { N
ba
}
# Inject a \n at the start and end of the pattern space
#
s/^\(.*\)\(\n\)\(.*\)$/\2\1\2\3\2/
# Quit if the R-flag was in the 3: line (Status).
#
/\n3:[^\n]*R/ q
# Remove any 3: line
#
s/\n3:[^\n]*//g
# Swap 2: and 1:, if in wrong order
#
s/\(\n2:[^\n]*\)\(\n1:[^\n]*\)/\2\1/
# Remove the field names
#
s/\(\n\)[12]: /\1/g
# Remove the \n from the start of the pattern space
#
s/^\n//
# Insert an arrow after the first \n
#
s/\n/&-> /1
# Print the pattern space.
#
p
--
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