Skip to content

Instantly share code, notes, and snippets.

@xtrmstep
Last active August 22, 2025 16:29
Show Gist options
  • Save xtrmstep/0efd0536718e6a557662f1bcd956f16d to your computer and use it in GitHub Desktop.
Save xtrmstep/0efd0536718e6a557662f1bcd956f16d to your computer and use it in GitHub Desktop.
Calculate hash of a folder #bash
#!/bin/bash
set -e
DIR=${1:-.}
# find all files in the DIR and its subfolders, excluding .zip files
HASH=$(
find "$DIR" \( -type d \( -name bin -o -name obj \) -prune \) -o \
-type f -not -name '*.zip' -print0 |
sort -z |
xargs -0 sha256sum |
sort | sha256sum | awk '{print $1}'
)
echo "{\"hash\": \"$HASH\"}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment