-
-
Save mimizone/10ac334cb7fac099c00dac34a54a9d79 to your computer and use it in GitHub Desktop.
compare the checksum of all files with the same name in 2 different folders
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 | |
CERROR='\033[0;31m' #Error color | |
COK='\033[0;32m' #Error color | |
NC='\033[0m' # No Color | |
IFS=$'\n' | |
offset=$(( ${#1} + 1)) | |
fnames=`find ${1} -type file -not -path '*/.*'` | |
for f in ${fnames} | |
do | |
s1=`shasum -a 256 ${f} | awk '{ print $1 }'` | |
s2=`shasum -a 256 ${2}/${f:$offset} | awk '{ print $1 }'` | |
if [ "$s1" != "$s2" ]; then | |
printf "${CERROR}ERROR \\t${NC}${f:$offset}\n" | |
else | |
printf "${COK}OK \\t${NC}${f:$offset}\n" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
more precisely, for all files in the first folder and its subfolders, it checks in the second directory if any other file with the same name and path as in the one in the first folder has the same checksum or not and displays a message OK or ERROR respectively with the path/filename of the file.
OK is green. ERROR is red.