procmail
[Top] [All Lists]

Re: Message count

1999-03-26 11:08:40
When I wrote that the number of messages stored in an mbox can be counted
more reliably this way,

| >  formail -s echo < $MAILFILE | wc -l

or even this way,

| >  FILENO=1 formail -s printenv FILENO < $MAILFILE | tail -1

than with  grep -c '^From ' < $MAILFILE,

Philip Guenther responded,

| There's no need for the echo or printenv.

We'll get back to echo.  For now, of course there is no need for printenv:
printenv is of use if you want to see each number spat out, though, as I
sometimes have needed.

| To paraphrase from a message
| you sent to the list in Dec 1996 (forget the Shadow; the _Net_ knows!):
| 
|       formail -I'From x' -zx'From ' -s < mailbox | wc -l

For the record, the  formail -I'From x' -zx'From ' -s  idea was Stephen's; I
may have repeated it in the message Philip cites, but I cannot claim to have
originated it.

| Two processes, two bytes down the pipe per message, and it gets
| Content-Length headers right.

Ah, but if the command is interpreted by a shell that has echo built in, then
the suggestion I made that uses echo also has only two processes, and it
sends only ONE byte per message down the pipe.  It's also a lot easier to type.

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