procmail
[Top] [All Lists]

Re: Search last line of mail

2002-08-06 13:21:31
Steve Semple asked,

| I want to search the last line of the mail.

| can use  " sed -n '$p' " to look at the last line ...

and most of the time it won't do you any good, because the last line will
normally be blank.  I'm sure you want to look at the last non-blank line.

 :0B flags # if pattern is not right-anchored
 * pattern.*($)+^^
 action

 :0B flags # if pattern is right-anchored
 * pattern($)+^^
 action

| I want to look at the last line or even the last 2 lines for a particular
string.

To search the last two lines -- which I'm interpreting as "the last non-blank
line and the line above it" -- change the regexp to

 pattern.*$(.+$)?($)*^^
or
 pattern$(.+$)?($)*^^

respectively.


_______________________________________________
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>