Bill Moseley asked,
| What I can't remember how to do is to, say count words using wc within
| procmail and assign it to a variable.
|
| There must be an easier way than:
|
| :0biWc
| | wc -w >! tmp
|
| WORDS=`cat tmp`
|
| But that wouldn't work.
It ought to work except that it is vulnerable to race conditions and needs
a regional lockfile, but we can cure that by not using a temporary file:
:0b # no i or c or W needed
WORDS=|wc -w
The above I'm sure of; the following is theoretical and needs testing, but
if it works it would get a count without forking another process:
WORDS = 0
:0B # capital B for this one
* 1^1 [^ ]( | |$)
{ WORDS = $= }
The brackets enclose caret, space, tab; the parentheses enclose space, pipe,
tab, pipe, dollar.