Last active
May 24, 2017 22:26
-
-
Save joeljuca/154cb69673fe8191dd3445a52fa026f6 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# | |
# Calculates the MD5 hash of a given file. It uses hashing utilities powered by | |
# operating systems, but wraps them into a consistent interface. | |
OS=$( | |
case $(uname) in | |
(Darwin*) echo "mac";; | |
(Linux*) echo "linux";; | |
# TODO: implement MD5 hashing on Windows | |
# (Windows*) echo "windows";; | |
(*) echo "linux";; | |
esac | |
) | |
case $OS in | |
mac ) | |
md5 -q $1;; | |
linux ) | |
echo md5sum $1 | sed -E 's/([a-z0-9]{32}).+$/\1/';; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment