Skip to content

Instantly share code, notes, and snippets.

@vinaysshenoy
Created March 25, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinaysshenoy/1cfe060cfcbe8f26e7d47dcdacd11499 to your computer and use it in GitHub Desktop.
Save vinaysshenoy/1cfe060cfcbe8f26e7d47dcdacd11499 to your computer and use it in GitHub Desktop.
#!/bin/bash
sourceDirectory=${1}
targetDirectory=${2}
changedFile=
for file in $(ls $sourceDirectory)
do
sourceFile="$sourceDirectory/$file"
sourceChecksum=($(shasum ${sourceFile}))
targetFile="$targetDirectory/$file"
targetChecksum=($(shasum ${targetFile}))
if [[ "$targetChecksum" != "$sourceChecksum" ]]; then
changedFile=$file
break
fi
done
if [[ -z $changedFile ]]; then
exit 0
else
>&2 echo "$changedFile was changed!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment