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

Xu Wang <[email protected]> Thu, 26 May 2016 21:03:15 -0400
Newsgroups gmane.mail.procmail
Message-ID <CAJhTkNgrim=ZV75kkx2CHcOjKS5Ks=FC8gzKXiXgQ=vP-f=n-Q@mail.gmail.com>
On Thu, May 26, 2016 at 8:23 PM, John Levine <[email protected]> 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 [email protected] Thu May 26 20:55:32 2016
Date: Thu, 26 May 2016 20:55:32 -0400
From: Xu Wang <[email protected]>
To: [email protected]
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