procmail
[Top] [All Lists]

Re: extracting the date

2003-01-18 09:30:40
Kreemy asked,

| %grep -e "^Date: " old.mail
| Date: Sun, 6 Oct 2002 13:20:37 -0600
| Date: Sun, 06 Oct 2002 12:26:18 -0700
| Date: Sun, 6 Oct 2002 13:27:14 -0600
| Date: Sun, 6 Oct 2002 13:29:08 -0600
|
| I found that the first 6 characters where always " ddd, ", and I don't
| want those
|
| the next 11 characters are either
|
| "dd mmm yyyy" or "d mmm yyyy "
|
| so, the question is, how to distinguish the former from the latter
| easily so that ALL the folders end up being named "dd mmm yyyy"??  (add
| the leading 0 and strip the trailing space)

It's a crapshoot, because you can't control that header and there may be
garbage in it; the date in the From_ line is more reliable (and its format
will be consistent).  But I'd work from the right, not the left:

 # after extractor in first condition: eleven dots, space, two dots, colon
 # in second condition, eleven dots
 :0
 * ^Date:.*\/........... ..:
 * MATCH ?? ^^\/...........
 {
  DATE=$MATCH

  :0 # space between carets and extractor
  * DATE ?? ^^ \/.+
  { DATE=0$MATCH }
 }



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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