Tente isto:
#!/bin/bash
frm="[email protected]"
recipients="[email protected]"
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 "${dte}: 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 "${dte}: Data file has changed. Sent mail to $recipients" >> $log
fi