Last active
August 22, 2025 16:29
-
-
Save xtrmstep/0efd0536718e6a557662f1bcd956f16d to your computer and use it in GitHub Desktop.
Calculate hash of a folder #bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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