Skip to content

Instantly share code, notes, and snippets.

@chuckwagoncomputing
Created January 5, 2014 03:10
Show Gist options
  • Save chuckwagoncomputing/8263809 to your computer and use it in GitHub Desktop.
Save chuckwagoncomputing/8263809 to your computer and use it in GitHub Desktop.
ifchanged
badopts()
{
echo -e "Usage: ifchanged [command to check] [number of seconds to wait between checks] [command to execute if not changed] [command to execute if changed]"
exit
}
if [ $# -ne 4 ]; then
badopts
else
while true; do
RES=`$1`
sleep $2
NOW=`$1`
if [ "$RES" = "$NOW" ]; then
$3
else
$4
fi
done
fi
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment