Skip to content

Instantly share code, notes, and snippets.

@ismet55555
Last active January 27, 2023 14:30
Show Gist options
  • Save ismet55555/3b35df54dacf26f91708dfc1499b8652 to your computer and use it in GitHub Desktop.
Save ismet55555/3b35df54dacf26f91708dfc1499b8652 to your computer and use it in GitHub Desktop.
Get a shortened hash of a directory that has been zipped up
#!/bin/bash
DIRECTORY_PATH="some/path/dir"
LENGTH=10
zip --quiet --recurse-paths TEMP.zip \
${DIRECTORY_PATH} \
--exclude "**/<SOME SUB DIR>/*" "**/*.<SOME FILE EXTENSION>"
shasum -a 256 TEMP.zip \
| awk '{ print $1 }' \
| tail --bytes ${LENGTH)
rm -f TEMP.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment