Last active
August 29, 2015 14:12
-
-
Save za3k/7e781521d1eaabac8ced to your computer and use it in GitHub Desktop.
md5sum expanded to work for directories
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 | |
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