Попробуй это:
#!/bin/bash frm="Datafile-Monitor@mycompany.com" recipients="dave@mycompany.com" current=/scripts/results/curfile.fil new=/scripts/results/datafile.fil log=/var/log/datafile msgfile=/scripts/results/mesg dte=`/bin/date` diff $current $new &>/dev/null if [ $? -eq 0 ]; then echo "$: Data file is: $new " >> $log else echo "Current STL Datafile has changed TO: " > $msgfile cat $new >> $msgfile mail -s "Alert! Data File has changed" -r "$frm" $recipients < $msgfile sleep 3 cat $new > $current echo "$: Data file has changed. Sent mail to $recipients" >> $log fi