diff --git a/hashdiff b/hashdiff new file mode 100755 index 0000000..f9bb29e --- /dev/null +++ b/hashdiff @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Compare two files by hash. +# Based on http://alanwsmith.com/command-line-one-liner-to-compare-files-with-md5 + +# Future enhancements: +# * different hashes +# * "paranoid" mode (use several different hashes) +# * compare more than two files +# * verbose: print out hashes if different + +file1=$1 +file2=$2 + +if [ $(md5 -q ${file1}) == $(md5 -q ${file2}) ] +then + echo "identical" +else + echo "different" +fi