#!/bin/ksh -p

Mail="/var/mail/$(whoami)"

grep -n "From.*[12][0-9][0-9][0-9]" $Mail | sed "s/:.*//" > as1.$$

set -A k 0 $(cat as1.$$) $(cat $Mail | wc -l)

NoOfMsgs=$(( ${#k[*]} - 2  )) 
# would normally be - 1)) but there's an EOF number to contend with too

#Halfway=$((NoOfMsgs / 2))

Mesg=13 #$Halfway
Next=$((Mesg + 1))

Start=${k[$Mesg]}
End=$(( ${k[$Next]} - 1 ))

echo "Message #$Mesg"
sed -n "${Start},${End}p" $Mail > as2.$$

toline=$(grep "To:" as2.$$)
echo $toline


/usr/bin/rm as?.$$
