Skip to content

Instantly share code, notes, and snippets.

@joseraya
Created November 26, 2012 12:31
Show Gist options
  • Save joseraya/4147963 to your computer and use it in GitHub Desktop.
Save joseraya/4147963 to your computer and use it in GitHub Desktop.
Watch a directory and execute something whenever a file is changed
#!/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 $*
@joseraya
Copy link
Author

example: watch markdoc build
will invoke markdoc build every time a file is changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment