Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: Re: awk (was tcl/tk + sed, was bash)



--------------------------------------------------------
tlug note from Jason Molenda <crash@example.com>
--------------------------------------------------------
Jim S wrote:

> Just thought I'd pass along this quick hack into Tcl/Tk I did for
> the earlier bash question - not too useful but it was fun...


Well my fragile ego won't have any of that!

This handles multiple messages in one input stream.  It either takes
stdin or filenames on the command line.  It eats up whitespace at the
beginning of messages.  It isn't particularly pretty, or useful. :-)



Jason
==================================================
#! /bin/sh

# ignores the Content-Length: header, assumes messages start with "From_".

# would be easy to have it print out the sender at the top of the message--just
# look for ^From: while inheader and save the string until we're no longer in
# the e-mail header.

awk '{
   if ($1 == "From") 
   {
     inheader = 1                 #  we are in the header of an e-mail message
     continue
   }
   if (inheader)
   {
     if (NF == 0)                # blank line
     { 
       eatblanks = 1
       continue
     }
     if (eatblanks && NF > 0)    # start of actual message text
     {
       if (morethanone)          # print ^L iff we have more than one msg
       {
         print ""
       }
       print
       inheader = 0              # we are no longer in the e-mail header
       eatblanks = 0
       morethanone = 1
     }
     continue                    # skip this header line
   }
   print
}' $* | lpr
-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links