Reading Huge UnixMailbox Files

Dan Stromberg drsalists at gmail.com
Tue Apr 26 17:02:23 EDT 2011


On Tue, Apr 26, 2011 at 1:23 PM, Nobody <nobody at nowhere.com> wrote:
> E.g. the following script reads a mailbox on stdin and writes a separate
> file for each message:
>
>        #!/usr/bin/awk -f
>        BEGIN {
>                num = 0;
>                ofile = "";
>        }
>
>        /^From / {
>                if (ofile != "") close(ofile);
>                ofile = sprintf("%06d.mbox", num);
>                num ++;
>        }
>
>        {
>                print > ofile;
>        }

For the archive: This assumes traditional mbox.  A SysV-ish sendmail,
for example, may not like it.



More information about the Python-list mailing list