#!/bin/bash # make sure we can find wget if ! which wget 2> /dev/null 1> /dev/null; then echo "Can't find wget in PATH" exit 1 fi # make sure we have acceptable args if [[ $# -lt 2 ]] || echo $2 | grep -E '[^0-9]+' > /dev/null; then echo $0: watch a webpage for changes echo usage: $0 " " exit 1 fi # get the md5sum of the page new=$(wget -qO- "$1" | md5sum) changes=0 # refresh the page at the specified interval, and compare the md5sum while [ true ]; do old=$new new=$(wget -qO- "$1" | md5sum) [[ "$old" != "$new" ]] && ((changes++)) echo "$(date '+[%l:%M:%S %p]') CHANGES: $changes" sleep $2 done