Skip to content

Instantly share code, notes, and snippets.

@chuckwagoncomputing
Created November 20, 2012 17:44
Show Gist options
  • Save chuckwagoncomputing/4119544 to your computer and use it in GitHub Desktop.
Save chuckwagoncomputing/4119544 to your computer and use it in GitHub Desktop.
shell script to check results of command
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