Created
December 9, 2015 11:21
-
-
Save skratchdot/8053931ee7f3e30dec9d to your computer and use it in GitHub Desktop.
Get the shasum hash of an entire directory (recursively)
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/sh | |
find ./src -type f -print0 | sort -z | xargs -0 shasum | shasum |
Use LC_ALL=C sort -z
if you want consistent sort order across different locales/environment settings.
@YourMJK - good call! i guess this is better:
#!/bin/sh
find ./src -type f -print0 | LC_ALL=C sort -z | xargs -0 shasum | shasum
Stumbled across this while doing some benchmarks for a Rust crate I wrote to hash directories.
If a package installation isn't too much, give paq a try.
@gregl83 - nice! thanks for adding this link / sharing your project. it looks pretty cool (and i like the explanation in the "how it works" section).
@skratchdot np, maybe it's helpful for another person!
There are trade-offs. The original solution should work on nix systems without requiring additional packages.
You might consider explicitly using SHA256
in your shasum
invocations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good