From 78815cf4c44119dd709c9716204da25886e15963 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Fri, 26 Jun 2020 08:09:55 -0700 Subject: [PATCH] Check a website for changes Usage: diffweb.sh https://domain.tld --- diffweb.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/diffweb.sh b/diffweb.sh index 1b790a0..8958941 100644 --- a/diffweb.sh +++ b/diffweb.sh @@ -1,5 +1,4 @@ #!/bin/bash - # diffweb - Checks a website for changes # Usage: diffweb https://domain.tld # Author: Justin Oros @@ -8,6 +7,7 @@ FILE1=/tmp/file1 FILE2=/tmp/file2 +# check to see if any input was given if [ -z $1 ] then echo "Usage: diffweb https://domain.tld" @@ -21,7 +21,7 @@ then # if file1 exists # store to file2 curl -s $1 > $FILE2 else # if file1 does not exist - # notify user of first run + # notify user this is the first run echo "diffweb has not run before for $1" # get website data # store to file1 @@ -31,14 +31,15 @@ fi # check to see if file2 exists if test -f $FILE2 then - # compare files - if cmp -s $FILE1 $FILE2 - then - echo "$1 has not changed." - else - # notify user website has changed - echo "$1 has been updated!" - # clone file2 to file1 - cat $FILE2 > $FILE1 - fi + # compare files + if cmp -s $FILE1 $FILE2 + then + # notify user website has not changed + echo "$1 has not changed." + else + # notify user website has changed + echo "$1 has been updated!" + # clone file2 to file1 + cat $FILE2 > $FILE1 + fi fi