This is a little program written in bash shell to detect two files differ.
#! /bin/bash
while :
TEXT=$(diff a.txt b.txt)echo $? $TEXT
do
if [ $TEXT=="" ]; then
echo "waiting....."
sleep 0.1
else
echo "Got it---it's differ now!"
exit
done