Gary asked,
F> headers from all the e-mails in an mbox? Let's say, I want to
F> send only the headers, collected together in an mbox format,
F> for a group of messages already deposited in an mbox.
F> Something like this?
F> formail -s sed -e '/^$/q' < foo.mbox > foo_hdrs.mbox
Philip answered,
G> One process, not N:
G> formail -X "" -s < foo.mbox > foo_hdrs.mbox
Or, if procmail and its companions are not [yet] installed,
sed -n '/^From /,/^$/p' < foo.mbox > foo_hdrs.mbox
though it will be fooled by body lines beginning with "From " that had been
protected by Content-Length: headers. That can be reduced somewhat by using
a fancier regexp to match postmark lines, but it works better to install and
use formail.
| Beware: any Content-Length: headers in that pile of messages will not
| contain the correct value (zero), so any future splitting should include
| the -Y flag.
That problem can be nipped in the bud:
formail -iContent-Length: -X "" -s < foo.mbox > foo_hdrs.mbox
Then one doesn't need to remember which folders need -Y.