Skip to content

Instantly share code, notes, and snippets.

@pasdam
Created April 25, 2023 08:37
Show Gist options
  • Save pasdam/57fe4cdb3a28da591963c0baad31bc7d to your computer and use it in GitHub Desktop.
Save pasdam/57fe4cdb3a28da591963c0baad31bc7d to your computer and use it in GitHub Desktop.
#!/bin/bash
PATH_TO_WATCH=$1
COMMAND=$2
trap printout SIGINT
printout() {
echo ""
1>&2 echo "Watch path terminated forcefully"
exit
}
while true
do
watch -d -t -g ls -lR ${PATH_TO_WATCH} > /dev/null && RES=$? && eval "${COMMAND}"
printf "\n\n\n-------------------\n\n\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment