Add script to generate shasum from folder

This commit is contained in:
Mario Hüttel 2022-07-29 18:57:26 +02:00
commit b6c71d15b3

27
dirsha256sum Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
if [[ -z $1 ]]; then
echo "Usage: $0 <path to folder>"
exit -1
fi
if [[ ! -d "$1" ]]; then
echo "Specified path: $1 is not a directory"
exit -2
fi
search_dir="$1"
filelist=()
while IFS= read -d $'\0' -r file ; do
filelist=("${filelist[@]}" "$file")
done < <(find "$search_dir" -type f -print0)
echo "Found ${#filelist[@]} files"
# Calculate shasums over all files
shasum=`for file in "${filelist[@]}"; do
sha256sum "$file"
done | sha256sum | sed 's/\s-//'`
echo "$shasum"