você pode usar inotifywait , leia mais
inotifywait - wait for changes to files using inotify
inotifywait efficiently waits for changes to files using Linux's inotify(7) interface. It is suitable for waiting for changes to files from shell scripts. It can either exit once an event occurs, or continually execute and output events as they occur.
use este comando:
$ inotifywait -m -e modify /tmp/testfile
quando eu escrevo em testfile , inotifywait alarm para mim
por exemplo:
echo "bh" > /tmp/testfile
inotifywait mostrar esta mensagem:
$ inotifywait -m -e modify /tmp/testfile
Setting up watches.
Watches established.
testfile MODIFY
testfile MODIFY
você também pode redirecionar a saída para while statement:
while read j
do
echo "file changed"
break
done < <(inotifywait -q -e modify /tmp/testfile)