Created
November 26, 2012 12:31
-
-
Save joseraya/4147963 to your computer and use it in GitHub Desktop.
Watch a directory and execute something whenever a file is changed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
check() { | |
chsum1=chsum2 | |
while [[ true ]] | |
do | |
chsum2=`find . -type f -exec md5 {} \;` | |
if [[ $chsum1 != $chsum2 ]] ; then | |
echo "Change detected ..." | |
eval $* | |
chsum1=`find . -type f -exec md5 {} \;` | |
fi | |
sleep 2 | |
done | |
} | |
check $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example: watch markdoc build
will invoke
markdoc build
every time a file is changed