This little bash script will watch several files for changes and serves as the basis for more complicated scripts that actually do something when a change is detected. It’s simply a matter of comparing the output of stat every 5 seconds
#!/bin/bash
count=0
for var in "$@"; do
count=$(($count + 1));
files[$count]=$var;
stats[$count]=`stat -r "$var"`;
done
while [ true ]; do
i=1
while [ $i -le $count ]; do
newstat=`stat -r "${files[i]}"`
if [ "$newstat" != "${stats[i]}" ]; then
echo \"${files[i]}\"
stats[$i]=$newstat
fi
i=$(($i+1))
done
sleep 5
done


My WordPress powered website has been running for quite some time now, and today I finally replaced the default theme with something I like better, 