Created
March 17, 2019 10:17
-
-
Save lrodorigo/69da1b9169acf621258235773bc59cc5 to your computer and use it in GitHub Desktop.
Watch for file changes in sh
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 | |
FILE_TO_WATCH=$1 | |
OLD=`sha1sum $FILE_TO_WATCH` | |
NEW=$OLD | |
while true; do | |
sleep 1 | |
NEW=`sha1sum $FILE_TO_WATCH` | |
if [ $? -ne 0 ] | |
then | |
OLD=0; | |
continue; | |
fi | |
if [ "$NEW" = "$OLD" ] | |
then | |
continue; | |
fi | |
echo 'File Cambiato!' | |
OLD=$NEW | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment