Yes, I know md5sum has a “-c” option for checking the checksum in a file … but, if I was going to screw with a file, I’d have the good sense to edit the checksum file in the archive!
#!/bin/bash #STRFILE=dead.letter #STRCHECKMD5=5f3748d9c653b78c9ee7559acd423652 #STRMD5=`md5sum $STRFILE` STRFILE=$1 STRCHECKMD5=$2 STRMD5=`md5sum $STRFILE` diff -s <( printf '%s\n' "$STRCHECKMD5 $STRFILE" ) <( printf '%s\n' "$STRMD5" )
It’ll either output the file hash and the hash to match (a problem) or indicate the files are identical (a good thing)