Skip to content

Instantly share code, notes, and snippets.

@arnold-almeida
Created November 14, 2010 02:31
Show Gist options
  • Save arnold-almeida/675853 to your computer and use it in GitHub Desktop.
Save arnold-almeida/675853 to your computer and use it in GitHub Desktop.
Monitor files in a directory, do stuff when contents change.
#!/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