[X-Unix] parsing a file into smaller files

Brian Medley bpm-list-osx-unix at 4321.tv
Sun May 29 01:51:34 PDT 2005


On Sat, May 28, 2005 at 11:53:48PM -0400, David Haines wrote:

> I'm sure this is possible, but simply beyond my current know-how.
> 
> I have a file that is really the collected text of hundreds of emails, that
> I need to parse out into multiple individual files, rather than the one
> collected file I have.
> 
> So then, could I use Perl perhaps, to generate a new file, taking everything
> from the text: 
> From:
> up to but not including the next instance of:
> From:
> 
> and then beginning with that next occurrence of "From:", separate the next
> bit of text out to another file, and so on (etc.)
> 
> Any/all tips/advice/input welcome.

What I would do is convert the mbox file (I'm assuming it's mbox
based on your description) and convert to maildir.  Then once you
have the maildir, you can run a perl script over the generated
files and rename them.

The following program can be used to convert the mbox to maildir:

http://batleth.sapienti-sat.org/projects/mb2md/

-- 
~`^`'~=-._.-=~'`^`'~=-._.-=~'^'~=-., \|/  (___)  \|/ _,.-=~'`^`
                                      @~./'O o`\.~@
      "Knowledge is Power"           /__( \___/ )__\  *PPPFFBT!*
         -- Francis Bacon               `\__`U_/'
 _.-=~'``'~=-._.-=~'``'~=-._.-=~'`^`'~= <____|'  ^^`'~=-.,__,.-=
~'^`'~=-._.-=~'`^`'~=-._.-=~'^'~=-.,__,.-==--^'~=-.,__,.-=~'`^`


More information about the X-Unix mailing list