while true do tail -f file.log | grep -q 'ERROR' if [ $? -eq 0 ] ; then cat file.log | /usr/bin/mailx -s 'logfile error' me@whereIam.com break fi done