#!/bin/rc mbox=mbox if ( ! ~ $#* 0 ) mbox=$1 switch($mbox){ case /* ; case * mbox=/mail/box/$user/$mbox } if ( ! test -r $mbox ){ echo from: $mbox - cannot read exit 'read fail' } sed -n ' /^From /,/^$/ { /^From: /{ s/.*"([^"]+)".*/\1/ s/.*<([^>]+)>.*/\1/ s/From: // y/#/-/ s/$/ / s/^(................................).*/\1/ s/^/FROM/ H } /^Subject: /{ s/^Subject: // y/#/-/ s/^/SUBJ/ H } /^$/{ x s/^FROM([^}]*)\n^SUBJ([^}]*)/\1\2/ s/^SUBJ([^}]*)\n^FROM([^}]*)/\2\1/ s/^FROM([^}]*)/\1/ s/\n// p d h } }' $mbox