Created
March 25, 2020 10:38
-
-
Save vinaysshenoy/1cfe060cfcbe8f26e7d47dcdacd11499 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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