Just use formail
. formail
is a program that can process mailbox, run some actions for each message in the mailbox, separate messages and so on.
More info: http://www.manpagez.com/man/1/formail/
If you want just split a mailbox to separate files,
I would suggest such solution:
$ cat $MAIL | formail -ds sh -c 'cat > msg.$FILENO'
From man:
FILENO
While splitting, formail assigns the message number currently
being output to this variable. By presetting FILENO, you can
change the initial message number being used and the width of the
zero-padded output. If FILENO is unset it will default to 000.
If FILENO is non-empty and does not contain a number, FILENO gen-
eration is disabled.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…