[comp.mail.misc] from.sed

john@trigraph.uucp (John Chew) (12/21/89)

Here's a new version of from.sed, my sed script that does the job
of from(1) better and faster.  It now truncates long subjects,
correctly handles messages without subjects and From lines with %
or @foo: routing.

To use it, save the lines below in a file (say from.sed) and either 
define an alias to invoke sed (sed -f from.sed /usr/spool/mail/john)
or wrap a teeny shell script around it to do the same thing (not
recommended, as the point of the script was to save the sort of
time that would get wasted by the shell).

Yes, I tried writing this in Perl.  I'm not an expert Perl programmer,
but I couldn't get it to run faster than about 70% slower than sed.

If you install this and find that large portions of mail headers
work their way into your output, your sed does not support the
magic '#n' comment.  I haven't found any seds that do, nor any
sed documentation that mentions the comment, so send me mail and
invoke the script with `sed -n' instead of just `sed'.

Bug reports, entertaining flames, shameless flattery welcome.

John
----- begin from.sed -----
#n from.sed v1.2 Copyright (C) 1989 John Chew <poslfit@gpu.UTCS.UToronto.CA>

/^From /!d
s///
s/^[^ ]*[!:]\([^ !:]*\) /\1 /
s/^\([^ @%]*\)[@%][^ ]* /\1 /
s/ /           /
s/^\(..........\)[^ ]* *\(.*\)/\2 \1/
h
: loop
  n
  /^$/!b    hdr
    g;p;d;: hdr
  /^Subject:/!b loop
s/^\(Subject: ...........................................\).*/\1/
H;g;s/\nSubject: */ /p
----- end from.sed -----
-- 
john j. chew, iii   		  phone: +1 416 425 3818     AppleLink: CDA0329
trigraph, inc., toronto, canada   {uunet!utai!utcsri,utgpu,utzoo}!trigraph!john
dept. of math., u. of toronto     poslfit@{utorgpu.bitnet,gpu.utcs.utoronto.ca}