From cd048610de206496e6c89872124515d593b84025 Mon Sep 17 00:00:00 2001 From: Darth Kilroy Date: Sat, 2 Aug 2025 23:03:48 -0500 Subject: [PATCH] Create sha.sh --- sha.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sha.sh diff --git a/sha.sh b/sha.sh new file mode 100644 index 0000000..67b477c --- /dev/null +++ b/sha.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Creates a .sha256 file with the same subfolders and each file (so creates a directory tree identical to the original. +SRC_DIR="/data" +DATE=$(date +%Y%m%d_%H%M%S) + +find "$SRC_DIR" -type f | while read -r file; do + # Get the directory and filename relative to SRC_DIR + rel_dir=$(dirname "${file#$SRC_DIR/}") + filename=$(basename "$file") + # Create a log directory for this file + log_dir="/tmp/$rel_dir/$filename" + mkdir -p "$log_dir" + # Generate sha256 and save to $DATE.sha256 inside the log directory + sha256sum "$file" > "$log_dir/$DATE.sha256" +done