procmail
[Top] [All Lists]

Re: Extracting a word from the Subject Line

1996-09-10 23:28:09
I know there must a simple solution for this that
can be integrated into a .procmailrc script, but 
whatever it is eludes me and I have wasted the last
12 hours hacking and scouring the Web to no avail.

We have a mail message containing the header

Subject:  Much Big News #1234xxx

In a .procmailrc script, we have...

TOPIC = `formail -x Subject|sed 's/[ ][^ ]*$//'`

$TOPIC now equals "Much Big News" and we have stripped
off the "#1234xxx"

But how do you get that last word (which happens to be
a password) into a variable using sed???  What I need
is to be able to do something like

Try this:

  PASSWORD=`formail -zxSubject: | awk '{print $NF}'`

Using "awk", 'print $NF' will always print the last field.

To lose the '#', and if you guarantee that it will always be there, you
can do this:

  PASSWORD=`formail -zxSubject: | awk -F\# '{print $2}'



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