Created
November 14, 2010 02:31
-
-
Save arnold-almeida/675853 to your computer and use it in GitHub Desktop.
Monitor files in a directory, do stuff when contents change.
This file contains 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 | |
# Via http://www.unix.com/shell-programming-scripting/100979-folder-watch.html | |
DIR=foo | |
STATIC=contents | |
ls -al $DIR > contents.tmp | |
diff -q contents.tmp $STATIC | |
if [ ! $? -eq 0 ] | |
then | |
cp contents.tmp $STATIC | |
echo "Directory Changed" | mail -s "Directory Changed $DIR" [email protected] | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment