procmail
[Top] [All Lists]

Re: Extract last email from an email file (mbox format)

2016-05-26 20:03:27
On Thu, May 26, 2016 at 8:23 PM, John Levine 
<johnl-procmail(_at_)iecc(_dot_)com> wrote:
I do not want to process all the emails. I still wonder if I can just
process the last without going through every single one before the
last. The tac solutions above or tail solutions are more efficient but
the formail is more safe. ...

No, it's not.  They'll both find the same message boundaries.

Searching for '^From ' (which is not the same as From:) is how formail
and every other mbox processing program finds message boundaries.  It's
what the boundaries are.  Either the "tac" script or the similar tail -r
script I sent will work fine.

R's,
John

I see. Thank you for sticking with it and trying to help explain to
me. I really appreciate your time and your teachings!

I think I have a fundamental misunderstanding somewhere. Perhaps I am
not using the mbox format? The file I wish to get last message of is
the send file from mutt. Here is the last message, for example:

---------------------------------begin last message
From xu(_dot_)wang762(_at_)gmail(_dot_)com Thu May 26 20:55:32 2016
Date: Thu, 26 May 2016 20:55:32 -0400
From: Xu Wang <xu(_dot_)wang762(_at_)gmail(_dot_)com>
To: xuwang_test(_at_)gmail(_dot_)com
Subject: testing
Message-ID: <20160527005532.qqqqz5ydzzzzredg@zaowei>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.6.0.1 (2016-04-01)
Status: RO
Content-Length: 163
Lines: 8

Hello, this is....


From: will this be matched?
From how about this one?

NotAHeader: just curious if there are escapes
If there are no escapes, we'll find out..
---------------------------------end last message

So this is why I am not sure matching regex with "^From " is safe. It
will also match in the body.

I am sorry if I have caused confusion. I am trying to learn more and
enjoying the process but I feel bad to take the time of others.

Kind regards,

Xu
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>