[wellylug] Parsing Mail log files

Cliff Pratt enkidu at cliffp.com
Fri Oct 28 19:10:08 NZDT 2005


Jamie Dobbs wrote:
> I am trying to parse my mail log files to find out the
> number of messages received per day and the total size of
> the messages received.
> 
> The format of the log files is:
> 
>> From xxxxx  Fri Oct 28 14:25:12 2005
> Subject: FW: Emailing: super_cop_1_.wmv Folder:
> ~/Maildir/new/1130462726.5627_0.xxx
> 2442024
> 
> Getting the number of messages per day is pretty easy,
> and I have done in this way"
> 
> for f in ~/Maildir/log*; do echo "$f :" `grep "Folder:"
> "$f" | wc -l`; done
> 
> I would also like to be able to get the total
> bytes/kbytes of the messages received for the day and
> although I can see how it should be done logically I do
> not know how to translate this into a command for a shell
>  script like the above. Logic tells me that we want the
> last "word" of the line starting with the word "Folder:"
> and keep a running total of this. Can anyone advise how I
> can do this?
> 
I'd probably do it in Perl. I feel that it is better at
parsing strings than shell can be, though with awk and grep,
shell can do pretty well.

Cheers,

Cliff




More information about the wellylug mailing list