Skip to content

Instantly share code, notes, and snippets.

@abrasive
Created December 1, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abrasive/67dd9a3fdceab8081e6b to your computer and use it in GitHub Desktop.
Save abrasive/67dd9a3fdceab8081e6b to your computer and use it in GitHub Desktop.
#!/bin/sh
# usage: onchange [interval] "[command to monitor]" "[command to run]"
STATE=$(eval $2 | md5sum)
while true; do
sleep $1
NEWSTATE=$(eval $2 | md5sum)
if [ "$NEWSTATE" != "$STATE" ]; then
eval $3
STATE="$NEWSTATE"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment