linux script that monitors file changes within folders (like autospec does!) linux script that monitors file changes within folders (like autospec does!) linux linux

linux script that monitors file changes within folders (like autospec does!)


keywords are inotifywait & inotifywatch commands


After reading replies to other posts, I found a post (now gone), I created this script :-

#!/bin/bashsha=0previous_sha=0update_sha(){    sha=`ls -lR . | sha1sum`}build () {    ## Build/make commands here    echo    echo "--> Monitor: Monitoring filesystem... (Press enter to force a build/update)"}changed () {    echo "--> Monitor: Files changed, Building..."    build    previous_sha=$sha}compare () {    update_sha    if [[ $sha != $previous_sha ]] ; then changed; fi}run () {    while true; do        compare        read -s -t 1 && (            echo "--> Monitor: Forced Update..."            build        )    done}echo "--> Monitor: Init..."echo "--> Monitor: Monitoring filesystem... (Press enter to force a build/update)"run