On Mon Dec 16 1996, Timothy J Luoma wrote:
procmail is really getting to be fun. However, I'm realizing that
I don't know an awful lot about it, and I seem to be wanting to do
things that the man pages don't seem to make reference to.
:-)
I have sent off for the "best of procmail" list and expect it soon.
Oohaah! Mention of this has gone by me... where/how can I get my
hands on this?
Anyway, my current conundrum is this.
I get a certain mail message every day with the same subject from
the same person. The subject itself it _not_ very helpful. What I
would like is if I could get the third line of his email message,
dump his useless subject, and replace the subject with the third
line from the body.
It sounds easy enough, and I could do a 'head -3 | tail -1' to get
it, but I'm not sure how to get that and replace the subject without
destroying the rest of the message.
sed to the rescue. This will grab the third line (and only the third
line) from any file:
sed -n 3p
So create a recipe that:
- looks for this message,
- filters a copy of the body of the message through sed and put the
result into an environment variable, something like (untested):
LINE3=|sed -n 3p
- send the message through formail to replace the current subject
line with what you have obtained from line 3, eg:
| formail -i"Subject: $LINE3"
- deliver the message.
Hope this helps.
Cheers
Tony