commit b6c71d15b3a2ef6287ad82196a3c4a621e02981e Author: Mario Hüttel Date: Fri Jul 29 18:57:26 2022 +0200 Add script to generate shasum from folder diff --git a/dirsha256sum b/dirsha256sum new file mode 100755 index 0000000..5d90435 --- /dev/null +++ b/dirsha256sum @@ -0,0 +1,27 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + echo "Usage: $0 " + 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"