Skip to content

Instantly share code, notes, and snippets.

@mcmire
Created July 12, 2018 17:40
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 mcmire/1ffc1e369397be33184fef9cebf2081f to your computer and use it in GitHub Desktop.
Save mcmire/1ffc1e369397be33184fef9cebf2081f to your computer and use it in GitHub Desktop.
Calculate a checksum of multiple directories
#!/bin/bash
set -euo pipefail
uname=$(uname)
checksum() {
if [[ $uname == 'Darwin' ]]; then
md5 -r
else
md5sum
fi
}
find "$@" | LC_ALL=C sort | tar -cf - -T - --no-recursion | checksum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment