Created
September 14, 2025 08:05
-
-
Save zhangyoufu/67a50d198fbd3199c17a76a16651a650 to your computer and use it in GitHub Desktop.
Calculate multiple checksum for a single file
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 | |
| echo -n 'Size: ' | |
| if [[ $OSTYPE == darwin* ]]; then | |
| stat -f %z "$1" | |
| else | |
| stat -c %s "$1" | |
| fi | |
| (tee < "$1" > /dev/null \ | |
| >(echo "MD5: $(md5sum | cut -d' ' -f1)" >&3) \ | |
| >(echo "SHA-1: $(sha1sum | cut -d' ' -f1)" >&3) \ | |
| >(echo "SHA-256: $(sha256sum | cut -d' ' -f1)" >&3) \ | |
| >(echo "SHA-512: $(sha512sum | cut -d' ' -f1)" >&3) \ | |
| ) 3>&1 | sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment