Skip to content

Instantly share code, notes, and snippets.

@skull-squadron
Created September 1, 2025 05:22
Show Gist options
  • Save skull-squadron/bb453a89da56d2b1474de03c185bf6b1 to your computer and use it in GitHub Desktop.
Save skull-squadron/bb453a89da56d2b1474de03c185bf6b1 to your computer and use it in GitHub Desktop.
hash-checker - Generic recursive SHA256 creation and checking utility
#!/bin/sh
# shellcheck disable=2094
set -eu
cd "$(dirname "$0")" || exit 1
hash_file='hashes.txt'
case "${1-}" in
save) find . -type f -print0 ! -name "$hash_file" | sort -z | xargs -0 sha256sum | tee "$hash_file" ;;
check) sha256sum -c "$hash_file" ;;
*)
echo >&2
echo >&2 "$(basename "$0"): usage: $0 {save|check}"
echo >&2
echo >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment