Adam Grove wrote,
| I've just started using procmail seriously, and have encountered
| the following problem. I'm sure I'm making a silly mistake, but
| I have no idea what it is. Can someone help?
| I want to count the "size" of a message using various measures,
| eg the number of lines, the number of blank lines, the number of
| lines containing words, etc.
It baffles me too; now, all these recipes have "B" flags; are you sure that
your method of checking also looks only at the body? If you are using wc -l
or grep -c on the entire message, it will count qualifying lines in the head
as well.
| I've tried various recipes; here are three simple examples that fail for me:
|
| :0 B
| * 1^1 ^.*$
| { }
|
| NUMLINES = $=
|
| After this, $NUMLINES always gets set to a small number (usually 1, sometimes
| 2, or 3) no matter how many lines the message has. WHY?
You'll need to tell us more, Adam. That code works for me; in fact, it always
counts 1 too many because of the putative newline at the end.
But I do see that you have the "B" flag on the recipe and then you speak of
"how many lines the message has" rather than "how many lines the body has,"
so that's why I wonder if your method of double-checking the number is
mistakenly including the head.
| :0 B
| * 1^1 ^.+
| { }
* 1^1 ^.
should give the same results, btw.
| NUMLINES = $=
|
| :0 B
| * 1^1 ^.*[A-Z]
| { }
|
| NUMLINES = $=
|
| I don't see how is it possible that the latter recipe gives a larger count
| than the former. But that frequently happens.
Nor do I; something is truly weird there.
| On the other hand, about half the time the ^.+ does indeed count the number of
| nonblank lines correctly,
Are there lines containing spaces or tabs but no visible characters? ^.+
would count them but you might skip them if you were counting visually.
| ... but then the second recipe gives a count which is typically around 1/2
| the number of lines containing a letter.
Strange ... are you sure that the messages have not been altered by a
filtering recipe by this point?