Stripping a mail header

Scott Yelich scott at tab00.larc.nasa.gov
Fri Sep 28 06:39:01 AEST 1990


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 at cs.odu.edu>
 ODU/UNIX/BSD/X/C/ROOT/XANTH/CS/VSVN/
 -----------------------------------------------------------------------------



More information about the Comp.unix.questions mailing list