From b6c71d15b3a2ef6287ad82196a3c4a621e02981e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 29 Jul 2022 18:57:26 +0200 Subject: [PATCH] Add script to generate shasum from folder --- dirsha256sum | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 dirsha256sum 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"