Sorting mail files chronologically on Unix

Steven M. List itkin at mrspoc.Transact.COM
Tue Apr 30 06:48:12 AEST 1991


Leisner.henr801c at xerox.com writes:

>I'm writing a program to convert mail files from one format (on one system) to
>another.
>
>The source mail file file has mail notes in a  well-defined format, which are
>not necessarily sorted chronologically.
>
>There is a sort command (in the mail tool) on the source system, which sorts a
>table of contents file chronologically.  The mail file is untouched.
>
>How do I sort a mailfile chronologically on Unix?  I looked in the
>documentation for Mail (the man pages) and saw nothing about sorting.  Figured
>this is useful and someone already did this...

The way that Elm allows you to do this is in a couple of steps:

    1.  Sort the "table of contents" in whatever order you want it
    2.  Tag all the messages
    3.  Save all tagged messages to an alternate file
    4.  Replace the original mail folder with the alternate

Since Elm saves messages in the same order in which they're displayed in the
"table of contents", you have the flexibility to order them whatever way
you wish.

Borrowing from this approach, you need only create an index of the messages
including whatever information you might wish to sort on, sort that index,
and then use the position information (which you also saved) to write out
the messages in the order in which they're sorted.  Note that you still
need to create an intermediate, temporary file to write the sorted
messages to before overwriting the original folder.

If someone actually goes to the trouble to develop such a program, I'm
sure that they'd find a large number of people who'd be interested in it.
It'd be particularly useful when retrieving multipart uuencoded files in
putting them in the right order!
-- 
 +----------------------------------------------------------------------------+
 :                Steven List @ Transact Software, Inc. :^>~                  :
 :           Chairman, Unify User Group of Northern California                :
 :                         itkin at Transact.COM                                 :



More information about the Comp.unix.questions mailing list