Skip to content

Instantly share code, notes, and snippets.

@baens
Last active August 29, 2015 14:20
Show Gist options
  • Save baens/635c471463f3b540ecb0 to your computer and use it in GitHub Desktop.
Save baens/635c471463f3b540ecb0 to your computer and use it in GitHub Desktop.
Bash watching
#!/bin/bash
trap 'kill -TERM $pid' TERM INT
source=$1
shift
command=$*
eval "$command &"
export pid=$!
while inotifywait -e modify,move,create,delete -r $source
do
pkill -TERM -P $pid
eval "$command &"
pid=$!
done
#!/bin/bash
source=$1
shift
command=$*
eval $*
while inotifywait -e modify,move,create,delete -r $source
do
eval $*
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment