Skip to content

Instantly share code, notes, and snippets.

@lrodorigo
Created March 17, 2019 10:17
Show Gist options
  • Save lrodorigo/69da1b9169acf621258235773bc59cc5 to your computer and use it in GitHub Desktop.
Save lrodorigo/69da1b9169acf621258235773bc59cc5 to your computer and use it in GitHub Desktop.
Watch for file changes in sh
#!/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