Re: Extract last email from an email file (mbox format)
Xu Wang <[email protected]> Mon, 30 May 2016 12:36:53 -0400
| Newsgroups | gmane.mail.procmail |
|---|---|
| Message-ID | <CAJhTkNh7_EpTdOp_nd+dvrVfACCkapQdwjsoJK108VSCo8Ry5A@mail.gmail.com> |
On Mon, May 30, 2016 at 6:12 AM, udi M <[email protected]> wrote: > > > On 29/05/16 23:11, Xu Wang wrote: >> >> On Sun, May 29, 2016 at 5:35 AM, udi M <[email protected]> wrote: >>> >>> >>> On 27/05/16 22:45, Xu Wang wrote: >>>> >>>> On Fri, May 27, 2016 at 10:09 AM, Zhiliang Hu <[email protected]> >>>> wrote: >>>>> >>>>> On Thu, 26 May 2016, Xu Wang wrote: >>>>> >>>>>> Date: Thu, 26 May 2016 21:03:15 -0400 >>>>>> From: Xu Wang <[email protected]> >>>>>> Subject: Re: Extract last email from an email file (mbox format) >>>>>> >>>>>> Hello, this is.... >>>>>> From: will this be matched? >>>>>>> >>>>>>> From how about this one? >>>>>> >>>>>> ---------------------------------end last message >>>>>> >>>>>> So this is why I am not sure matching regex with "^From " is safe. It >>>>>> will also match in the body. >>>>> >>>>> >>>>> As a tradition, when a mail is saved into mbox format, any leading >>>>> "From" >>>>> line is prefixed with ">" as in your example. >>>> >>>> I see, so mutt must not be using mbox format then because it does not do >>>> that. >>>> >>>>> You could use 'H' or 'h' flag in your little rc file to check headers >>>>> only. >>>> >>>> What would be the full contents of little rc in this case? >>> >>> I do not know what Zhiliang means, but, I am afraid that you >>> did not check my last suggestion: By using formail(1) + tee(1) >>> you do not need any rc file ! >>> >>> Do only one simple command: >>> >>> formail -s tee oneMessageOnly < theBigBox >>> >>> >>> 1. formail works only on the headers (was dsiged for) >> >> Agreed. >> >>> 2. It will not create a big directory ! >> >> Agreed. >> >>> 3. It is fast. >> >> Unfortunately not for me. >> >> time formail -s tee oneMessageOnly < theBigBox >> >> real 0m24.019s >> user 0m3.376s >> sys 0m4.484s >> >> As mentioned, my file is huge: >> $ wc -l theBigBox >> 2171183 theBigBox >> >> And it will get huger. THe main thing though is I would like to >> eventually make my script open source and help others and want to >> allow them to have huge files as well. > > > My testoffers compromise: > > TIMEFORMAT=%2R > > #> wc -l ./old-y06/toro/mail/mail-orig/sent-mail-mar-2006 > 4017303 ./old-y06/toro/mail/mail-orig/sent-mail-mar-2006 > > #> time formail -s tee xxx < > ./old-y06/toro/mail/mail-orig/sent-mail-mar-2006 > ...output... > ...output... > 70.50 > > #> time formail -s tee xxx < > ./old-y06/toro/mail/mail-orig/sent-mail-mar-2006 >/dev/null > 10.49 Ah yes that is great improvement! For me as well. Redirecting is a good idea. > > Running the tac(1) is much! faster! but, you the pipe call three jobs > parallel but the > last tac(1) (in the right side) must wait for the left jobs to finish, maybe > needs more > memory. As you mentioned it is dilemma, if the script supposed to run in > background > the time is less problematic - it is your choice. OK I will consider all possibilities. Thank you so much for the helping. Highest regards, Xu > > > > >> >> I would like use this in script and use it often so 24 seconds is too >> much for me. >> >> Udi, thank you so much for your continued help and explanations. I >> really appreciate your time! >> >> Kind regards, >> >> Xu >> >>> --udi > >