On Thu, Apr 12, 2012 at 10:43:24AM -0700, Chip Camden wrote: > If you're using mbox format, then this ruby script will output the number > of new messages in an mbox passed as an argument or piped to its stdin: > > #!/usr/bin/env ruby > UNIX_FROM = /^From \S+ ([A-Z][a-z]{2} ){2}[\s\d]\d \d{2}:\d{2}:\d{2} \d{4}$/
For what it's worth, this may be too restrictive in practice, for the general case. I believe the generally accepted regex is: ^From .+ (that's "^From" followed by SPC, followed by ".+"). The date format can be variable from client to client, and as we've seen on mutt-dev in the past IIRC, may be omitted entirely by some clients / MDAs. This is why most clients / MDAs will escape lines that start with "From" or use quoted-printable to encode messages containing them. Sadly there is no official standard which defines what should be in the From line which starts an mbox message, as there is no single formal standard for mbox message stores (there is RFC 4155, which is NOT for message stores -- otherwise you get whatever your vendor decided to implement). -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience.
pgpEn9AUNmwmU.pgp
Description: PGP signature