#### "The Linux Gazette...making Linux just a little more fun!"

# The Answer Guy

#### By James T. Dennis, linux-questions-only@ssc.com
LinuxCare, http://www.linuxcare.com/

### MATCH and Replaceable Parameters in procmail

From Nick Moffitt on Sat, 01 May 1999

So, here's one for the answer guy.

I have a mhonarc user that creates drop points for a mhonarc script to walk by every night and process. Thing is, I don't want to have to edit the mhonarc user's `.procmailrc` every single time. That is, let's say that I have the following:

    :0:
    * ^Sender: owner-potato-peelers
    spool/potato-peelers

    :0:
    * ^Sender: owner-onion-skinners
    spool/onion-skinners

Is there some way that I can automate this format? e.g.:

    :0:
    * ^Sender: owner-\([^@]+\)
    spool/$1

This likely breaks procmail's own regex syntax, but you get the point. "Anything that has an owner-foo Sender header should go to spool/foo."

> Nick,

> You have the right idea but, as you've guessed, the wrong syntax. The answer is to use the `MATCH` variable and the `\/` (fencepost) operator as described in this excerpt from the `procmailrc`(5) man page:

>            MATCH       This variable is assigned to by procmail when-
>                        ever  it is told to extract text from a match-
>                        ing regular expression.  It will  contain  all
>                        text  matching the regular expression past the
>                        `\/' token.

> So, your recipe would look something like:

>     :0:
>     * ^Sender: owner-\/.*
>     spool/$MATCH

> (though I haven't tested this specifically).

### procmail and saved variables.

From Nick Moffitt on Sun, 2 May 1999

[Jim Dennis said] So, your recipe would look something like:

> `
> :0:
> * ^Sender: owner-\/.*
> spool/$MATCH`

(though I haven't tested this specifically).

> I have! It works like a charm.

##### Copyright © 1999, James T. Dennis
Published in The Linux Gazette Issue 42 June 1999

###### HTML transformation by Heather Stern of Starshine Techinical Services, http://www.starshine.org/

| 1 | 2 | 3 | 4 | 5 | 6
7 | 8 | 9 | 10 | 11 | 12
13 | 14 | 15 | 16 | 17 | 18
19 | 20 | 21 | 22 | 23 | 24