OK, I've now used paste(1) about /three/ times in my life...
To re-flatten the output of egrep into a single line, as in:
egrep -e '^Date:|^From:|^Subject:' $mailfile | paste -d'|' - - -
Specifically, I'm working on Maildir-style files so I don't have to worry about "losing synchronization" if one of the headers is missing for some reason, and the names of the files are contained in the file "0006966d83811cd33a120e436a67d312".
so:
for i in $(cat 0006966d83811cd33a120e436a67d312 ); do (echo $i|cut -d'/' -f2 ; egrep '^Date:|^From:|^Subject:' ../$i ) | paste -d'|' - - - - ; done
produces output like:
.DNS|Date: Fri, 5 Jun 2009 21:16:22 -0400 (EDT)|From: "easyDNS Support" support@easydns.com|Subject: [easyDNS] Automated 30 day renewal reminder 2009-07-05 .DNS|Date: Fri, 5 Jun 2009 21:16:22 -0400 (EDT)|From: "easyDNS Support" support@easydns.com|Subject: [easyDNS] Automated 30 day renewal reminder 2009-07-05
which I can then feed into the next stage of parsing.
-Adam