[plug] print contents list of mbox folder

Russell russellsteicke at gmail.com
Mon Sep 18 13:14:24 WST 2006


On 9/17/06, Gavin Chester <sales at ecosolutions.com.au> wrote:
> Can't find _anywhere_ instruction on how I can print (hardcopy or to a
> formatted file) the list of emails in a folder such as /inbox/plug/ that
> is in (evolution) mbox format.  That is, I want to print out the email
> list with just the 'from', 'to', 'subject' being almost all that shows
> such that the output resembles what you see when looking at the list of
> email in your email client.

Trivial mbox parsing is easy.  Handling all the corner cases is hard.
Continuation lines (header lines starting with white space continue
the previous line) and slightly different From_ line formats are the
most obvious.  And I think that header field names are case-folded,
although almost everything uses "From" and "To" instead of "from" and
"to".

Here's a trivial awk script that ignores most of those cases:

#!/usr/bin/awk -f
BEGIN { Inheaders=0; }
/^From / { Inheaders=1; }
/^(To|From|Subject):/ { if (Inheaders) { print $0; } }
/^$/ { if (Inheaders) { Inheaders=0; print ""; } }



More information about the plug mailing list