How to Split up an MBOX file into individual emails

An MBOX file contains a bunch of emails, all joined together.  Each email is followed by a blank line.

To split the file up, back to the original emails, you look for lines that start with the Envelope From header (as opposed to the Email Header From: line.  Notice the space versus the colon that follows the same word From.)

Simple enough, unless the body of the email starts a line with From .

One solution is to use the formail program, which should be available on all Linux distributions.

cat mylistserve.mbox | formail -ds sh -c 'cat > msg.$FILENO'

The above command will create one file per email, and each email will be placed in a separate file, preceded by msg.