procmail
[Top] [All Lists]

Re: counting msgs in mbox

2003-10-08 16:21:43
Hehe.

To be honest, I came up with my "^From: " method sometime back in 1990  
for a script I was using to check counts in multiple inboxes and have been 
using the same method ever since.  I knew it had its limitations but never 
was bothered enough to examine it more.  I still use the exact same 
shell script today, but I updated it per this coversation. 

The last modified date on what I was using was March 3, 1990. *snicker*.

- Robert

On Thu, 9 Oct 2003, Dallman Ross wrote:

On Wed, Oct 08, 2003 at 11:56:51AM -1000, Baron Fujimoto wrote:
On Wed, 8 Oct 2003, Dallman Ross wrote:

: On Wed, Oct 08, 2003 at 03:13:26PM -0500, Robert A. Hayden wrote:
: >
: > grep "^From: " /var/spool/mail/rhayden | wc -l
:
: Not all that hot, Robert, if a good try.  For one thing, there's
: no need for grep piped to wc.  You can use the -c option with
: grep:
:
:   COUNT = `grep -c '^From:' $MAIL`
:
: (Note that I took your space out.  There is no RFC requirement for a
: space, and it also could be a tab.)  But as you state, it's easy to fool
: that test.

If you're trying to count messages in a file in mbox format, the regex
for the message delimiter should be "^From ".  This is not the same as the
"From:" header usually displayed by MUAs.  Note that this may also subject
to error if your LDA does not do "^From " escaping in message bodies -- see
the part about explicit delivery in the MISCELLANEOUS section of the 
procmail
man page.

Yes, certainly, you're right.  I wasn't touting that line I added
as the right answer.  It was just how I'd rewrite Robert's, if
I were Robert and really, really wanted to use From: for some
strange reason instead of From_.  Sorry I wasn't clear.  Again,
the "formail -s echo < $MAIL | wc -l" is what got my vote.




_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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