Created
July 20, 2019 20:10
-
-
Save stefanbirkner/c0cdb0e993ecc44861831aa96c0ce1b2 to your computer and use it in GitHub Desktop.
Create a checksum file in each directory
This file contains hidden or 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
#!/usr/bin/env bash | |
readonly FOLDER=$1 | |
create_checksum_file () | |
{ | |
local folder=$1 | |
local file="$folder/md5_sums" | |
echo "Create checksum file $file" | |
find "$folder" \ | |
-maxdepth 1 \ | |
-type f \ | |
-exec md5sum {} ';' \ | |
> "$file" | |
find "$folder" \ | |
-maxdepth 1 \ | |
-type d \ | |
-exec echo {} ';' \ | |
>> "$file" | |
sort "$file" -o "$file" | |
} | |
main () | |
{ | |
local folder=$1 | |
create_checksum_file $folder | |
find $folder \ | |
-type d | while read file; do create_checksum_file "$file"; done | |
} | |
main $FOLDER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment