Re: procmailrc syntax
"Ruud H.G. van Tol" <[email protected]> Sat, 29 Oct 2016 00:03:51 +0200
| Newsgroups | gmane.mail.procmail |
|---|---|
| Message-ID | <[email protected]> |
On 2016-10-28 22:07, Zhiliang Hu wrote:
> Although I used procmail for so long I never figure out what kind of
> "script" rules it follows. For example in one of my rc script I try to
> calculate a list file ("dist"):
>
> DISTCOUNT=3D`grep -cv '^(' dist` -1
>
> the calculation part fails, end up in the log:
>
> procmail: Skipped "-1"
>
> How can I get over this without getting it to external script for a
> simple calculation like this?
Let's use a bit of procmail:
test.msg, is a file with some lines of text,
and 18 of them don't start with an X.
test.rc:
# - - - - - - - - - -
TESTCOUNT=3D`grep -vc '^X' test.msg`
LOG=3D"$TESTCOUNT - 1 =3D "
:0
*$ $TESTCOUNT^0
* -1^0
{ TESTCOUNT=3D$=3D }
LOG=3D"$TESTCOUNT
"
# - - - - - - - - - -
# And then run it:
$ procmail -m test.rc < /dev/null
18 - 1 =3D 17
-- Greetings, Ruud