Skip to content

Instantly share code, notes, and snippets.

@BobbyRyterski
Created June 27, 2014 00:23
Show Gist options
  • Save BobbyRyterski/a7c7c6898529708f57d0 to your computer and use it in GitHub Desktop.
Save BobbyRyterski/a7c7c6898529708f57d0 to your computer and use it in GitHub Desktop.
md5_compare.sh
#!/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