Created
June 27, 2014 00:23
-
-
Save BobbyRyterski/a7c7c6898529708f57d0 to your computer and use it in GitHub Desktop.
md5_compare.sh
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 | |
error() { | |
echo "$*" | |
exit 1 | |
} | |
usage() { | |
echo "Usage: bash md5_compare.sh [A] [B]" | |
echo " Checks that all hashes in B are in A" | |
exit | |
} | |
main() { | |
[[ $# == 2 ]] || usage | |
local a="$1" | |
local b="$2" | |
local hashes=($(awk '{print $1}' "$b")) | |
for h in "${hashes[@]}"; do | |
grep "$h" "$a" &> /dev/null || error "Couldn't find hash=$h" | |
done | |
echo "All hashes found" | |
} | |
main $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment