#!/bin/bash
# run this on one terminal
# and on another terminal run: while [ 1 ] ; do sleep 5; touch /tmp/1111; done
# what do you observe?

touch /tmp/1111;
FILE=/tmp/1111
#FILE=$1
if [ -f "$FILE" ]; then
    echo "$FILE exists."
else 
    echo "$FILE does not exist."
fi

date1=`stat -c %y $FILE`
while [ 1 ]; do 
	date2=`stat -c %y $FILE`
	echo $date1
	echo $date2
	echo "--"
	if [[ "$date1" != "$date2" ]]; then
		echo "error!"
	fi
	date1=$date2
	sleep 1
done
