#!/bin/bash emailTo=ssullivan@liquidweb.com monitorDir=/something/to/monitor #monitorDir=/root/newfiletest count="0" while [ $count -lt "10" ]; do for i in $monitorDir do theLatest=`ls -At $i | awk '{ print $1 }' | head -n1` echo "Latest file is : $theLatest" > /dev/null 2>&1 if [[ "$theLatest" = "$theLatestOrig" ]]; then echo "No new file found!" > /dev/null 2>&1 else echo "New file found!" > /dev/null 2>&1 echo "new file `echo $theLatest` found in `echo $monitorDir`. Contents: `cat $monitorDir/$theLatest`" | mail -s "New File `echo $theLatest` found in `echo $monitorDir`" $emailTo fi done theLatestOrig=$theLatest sleep 3s done