Skip to content

Instantly share code, notes, and snippets.

@za3k
Last active August 29, 2015 14:12
Show Gist options
  • Save za3k/7e781521d1eaabac8ced to your computer and use it in GitHub Desktop.
Save za3k/7e781521d1eaabac8ced to your computer and use it in GitHub Desktop.
md5sum expanded to work for directories
#!/bin/bash
md5_folder() {
{
# Print md5 hash of every file
find "$1" -type f -print0 | sort -z | xargs -0 md5sum
# Print the names of all files and directories
find "$1" -printf %P\\0
} | md5sum | awk '{print $1}'
}
while [[ "$#" -gt 0 ]]
do
echo $(md5_folder "$1") "$1"
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment