#!/bin/sh # new_msgs # Andrew Davison (ad@ratree.psu.ac.th), August 1997 # The position of the new messages in $mspool are # collected in $msgs and stored in $ml.mno # The "From " lines in the current version of $mspool # are stored in $ml.nfroms, and compared with the old # "From " lines from previously (in $ml.ofroms). Any # lines which are not in $ml.ofroms must be new, and # their position are recorded in $msgs. mspool="/var/spool/mail/ad" ml="/home/ad/coding/mailer/mail" from > $ml.nfroms oldIFS="$IFS" # backup old separator IFS=' ' # make separator a newline count=1 for line in `cat $ml.nfroms` do grep -qsx "$line" $ml.ofroms # Is $line in old froms? if [ $? != 0 ] # If no then ... then msgs="$msgs $count" fi count=`expr $count + 1` done IFS="$oldIFS" # reset separator to old value mv -f $ml.nfroms $ml.ofroms # echo New message numbers: "$msgs" echo $msgs > $ml.mno