daemon() {
chsum1=""
while [[ true ]]
do
chsum2=`find src/ -type f -exec md5 {} \;`
if [[ $chsum1 != $chsum2 ]] ; then
if [ -n "$chsum1" ]; then
compile
fi
chsum1=$chsum2
fi
sleep 2
done
}
The fuck…
Even if you wanted to implement a solution like this, which you shouldn't, why on earth monitor the MD5 sum instead of just the mtime of the file???? Like, doing a checksum is the least efficient method of checking this possible.
Like, you could do a simple while loop with a find myfile.txt +mmin 1; sleep 30 in it. Adjust numbers to your desired tolerance.
Again, don't do that. But if you must, definitely don't do an md5sum for godssake.
I really like this, replace compile with whatever command you desire I guess.
Block execution not entirely. You could chmod it as non-x and use inotifywatch to flip it back.
Edit: I misunderstood you, use inotifywait like the other person suggested.
After some suggestions to check out inotifywait I ended up with a solution that works for me as desired.
It turned out I was interested in both file modification and file creation events.