cs201402@umbc5.umbc.edu (cs201402) (09/25/90)
Hi all, Gotta question on stripping mail headers. I'm using elm as my mailer, and I'm gonna have my students send me their projects via email. I was wondering if there is a sed command or some other Unix utility that would help strip the header so I can have a script file compile and run it for me. Thanks in advance. /* Robert Allen Gottlieb Internet: cs201402@umbc5.umbc.edu */ /* Bitnet: cs211123@umbc1 */ /* "I'd rather have a bottle in front of me..." */ /* These opinions herein are not that of UMBC, but that of Jr, my cat, */ /* and me. */
scott@tab00.larc.nasa.gov (Scott Yelich) (09/28/90)
Heh, I wrote one of these for our systems graders my first year here!
The problem is that I wrote it in csh (my login shell) before I learned
that csh was BAD to program in.
Anyway, I will tell you what I used, but I will not give you my code
(it's REALLY awful, and 3 years old!)
awk '$1 == "From" && NF == 7 && HEADER == 0 {HEADER=1;}\
HEADER == 0 {print $0 }\
NF == 0 {HEADER=0;}'
You can put that in a pipe and what comes out the other side will be
the body of the message. Switch ``HEADER == 0'' to ``HEADER == 1''
and you will only get the headers!
The above example works on an entire mail spool file.
If you are only going to do a single mail, try this:
awk 'NF == 0 {BODY = 1} BODY == 1 {print $0}' <$LETTER >$BODY
Good luck!
Scott
--
Signature follows. [Skip now]
-----------------------------------------------------------------------------
Scott D. Yelich scott@[xanth.]cs.odu.edu [128.82.8.1]
After he pushed me off the cliff, he asked me, as I fell, ``Why'd you jump?''
Administrator of: Game-Design requests to <game-design-request@cs.odu.edu>
ODU/UNIX/BSD/X/C/ROOT/XANTH/CS/VSVN/
-----------------------------------------------------------------------------pfalstad@phoenix.Princeton.EDU (Paul John Falstad) (09/28/90)
In article <SCOTT.90Sep27163901@tab00.larc.nasa.gov> scott@tab00.larc.nasa.gov (Scott Yelich) writes: >awk '$1 == "From" && NF == 7 && HEADER == 0 {HEADER=1;}\ > HEADER == 0 {print $0 }\ > NF == 0 {HEADER=0;}' >You can put that in a pipe and what comes out the other side will be >the body of the message. Switch ``HEADER == 0'' to ``HEADER == 1'' >and you will only get the headers! Or, try this: sed '/^From/,/^$/d' mailfiles ... To get the headers: sed -n '/^From/,/^$/p' mailfiles ... Paul Falstad, pfalstad@phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD I'd like to answer this question, if I may, in two ways. Firstly in my normal voice, and then in a kind of silly high-pitched whine.