Edit large mbox files
From MozillaZine Knowledge Base
Undeleting a message or trying to repair a corrupt folder sometimes requires a editor that can open a 1GB or larger file. Most text editors can't open that large a file. You normally need enough memory available for the original file plus a copy. The problem is that most 32 bit Windows applications can't access more than 2GB even if you have enough memory plus swap file available. Its possible to increase that to about 3GB by editing the boot.ini file settings and using a utility to set a flag in the .EXE's header but thats risky.
A safer solution is to use a text or hex editor that knows how to edit files larger than 1GB without having to load the entire file in memory.
If you're running a 64 bit operating system with 4GB of memory text editors such as Notepad++ (a notepad replacement) that can edit any file that can fit in virtual memory will work.
Emacs used to be a good solution but recent versions have a low filesize limit due to the elisp pointer representation. Textpad is another popular choice but it's limited to "file sizes up to the largest contiguous chunk of virtual memory". It can be hard to get a 1GB chunk if you don't have a lot of memory.
TextEdit.app (the standard text editor under OS X) supports editing large files, though its not clear what the limit is. Its also slow. 
You could use a file splitter such as Gsplit to split the file into several pieces, edit one or more of the pieces, and then have it recombine them. Gsplit can split 4GB files and creates a small program to join the pieces back together.
TextWrangler is a OS X text editor that can edit any file up to 384MB. This limit is because they store the entire file in RAM, and it's Unicode encoded. However, somebody said they used `split -b 300m foo.xml`to let them edit just part of a xml file that was too large.  You might be able to find a text editor that supports command line arguments for loading just part of the file into memory, and edit it in multiple steps.
Split a mbox file into two parts
There are utilities to split a file in two but there is no guarantee it won't split one of the messages into two parts. There are some utilities that will try to parse a mbox file and split each message into a separate file, but they don't work well if the mbox file is badly corrupted.
There is a From_ line before each message and a blank line after each message. A From_ line is a line that begins with the the characters F, r, o, m, space and contains the time and date. For example, From - Sun Jun 14 22:15:03 2009. See Recover messages from a corrupt folder for more information about the structure of a mbox file.