minus-squarerunning_ragged@lemmy.worldtoLinux Questions@lemmy.zip•Run a shell script whenever a file in a certain directory changes?linkfedilinkEnglisharrow-up3arrow-down5·2 months agoCan continuously loop over the file, examine the md5 hash for changes. Run the script if it has changed. https://stackoverflow.com/questions/6475252/bash-script-watch-folder-execute-command 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 } linkfedilink
Can continuously loop over the file, examine the md5 hash for changes.
Run the script if it has changed.
https://stackoverflow.com/questions/6475252/bash-script-watch-folder-execute-command