Skip to content

Instantly share code, notes, and snippets.

@Donluigimx
Created September 22, 2022 22:15
Show Gist options
  • Select an option

  • Save Donluigimx/2bca64fb01f55b03250bac64261ab14e to your computer and use it in GitHub Desktop.

Select an option

Save Donluigimx/2bca64fb01f55b03250bac64261ab14e to your computer and use it in GitHub Desktop.
Watch for changes on a folder, execute command on change
daemon() {
chsum1=""
while [[ true ]]
do
chsum2=`find src/ -type f -exec md5 {} \;`
if [[ $chsum1 != $chsum2 ]] ; then
if [ -n "$chsum1" ]; then
execute
fi
chsum1=$chsum2
fi
sleep 2
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment