Skip to content

Instantly share code, notes, and snippets.

@3noch
Created June 14, 2017 21:06
Show Gist options
  • Save 3noch/cd25540cc7627055e56c06d1bf6b54db to your computer and use it in GitHub Desktop.
Save 3noch/cd25540cc7627055e56c06d1bf6b54db to your computer and use it in GitHub Desktop.
Simple file watching script
#!/usr/bin/env bash
#You need inotifywait from inotify-tools
DIR=${1:?Specify a file or directory to watch}
CMD=${2:?Specify a command to run}
while true; do inotifywait -qr -e modify -e create -e delete "$DIR"; $CMD; sleep 1; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment