#!/usr/bin/env bash # # /usr/local/bin/md5 # # # Description: # Dirty hack to get "md5" (OS X style) onboard. Linux have "md5sum", # so as a wrapper &/or to use with other scripts as a layer. # # Just in case... if [[ ! `type md5sum 2>/dev/null` ]]; then echo "'md5sum' is not installed. Aborting..."; exit; fi # What mode? case $1 in # OS X man page: # -s string # Print a checksum of the given string. -s) shift; _text="$1" _md5=$(echo -n "$1" | md5sum -t | awk '{ print $1 }'); echo "MD5 (\"$_text\") = $_md5"; ;; # OS X man page: # -q Quiet mode - only the checksum is printed out. Overrides the -r # option. -q) shift; md5sum $@ | awk '{ print $1 }'; ;; # OS X man page: # -r Reverses the format of the output. This helps with visual diffs. # Does nothing when combined with the -ptx options. # # Output is same as md5sum --text -r) shift; md5sum $@; ;; # Linux man page: # --tag create a BSD-style checksum *) md5sum --tag $@ ;; esac # Bye-bye... exit;