<<< Date Index >>>     <<< Thread Index >>>

Re: mbox script



Re: juman in <20040128132858.GA29154@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
> I am looking in to writing some scripts helping me archive old
> email etc and having a hard time finding some information about how to
> read the mbox (yes I know maildir is better/easier but for the moment
> that is not an option).

The mbox format is really simple: each mail starts with "From " at the
beginning of a line (this means that you have to quote (like here) each
From that occurs there.)

> How do I go in and delete an email in a mbox without corrupting
> anything? I have understood that what I can do is copy the mbox, modify
> it and then copy it back but is that the best thing to do?

Unless there is another process writing to the same file (which
shouldn't be the case with old mail) you just open the folder, copy
every line to the new folder except those that belong to the mail you
want to delete and replace the folder by the new one.

Of course you can also read the whole folder into memory and put the
modified version back. Or just use Mutt and press 'd' ;-)

Christoph
-- 
Christoph Berg <cb@xxxxxxxxxxxxxxxx>, http://www.df7cb.de/
Wohnheim D, 2405, Universität des Saarlandes, 0681/9657944

Attachment: signature.asc
Description: Digital signature