Files
common/utils/shasum-files/get_sums.sh
2025-06-24 15:24:16 -07:00

13 lines
373 B
Bash

#!/bin/bash
# Get the directory and pattern as arguments
DIR=$1
PATTERN=$2
find "$DIR" -type f -name "$PATTERN" -print0 | while IFS= read -r -d '' file; do
# compute the sha256 hash of the file using sha256sum command
HASH=$(sha256sum "$file" | cut -d " " -f1)
NAME=$(basename "$file")
# print the file name and hash to a temporary file
echo "$NAME: $HASH"
done