0

md5suming a file is fine, but I cannot seem to invoke md5sum to calculate the hash based only on the file's contents. (For those wondering, I'd prefer that multiple wgets of the same file return the same md5 hash. md5summing the file keeps reporting different hashes because the timestamp on the file is different.)

julian@julian-computer:/tmp$ md5sum < `cat index.html`
bash: `cat index.html`: ambiguous redirect
  • 6
    md5sum index.html, md5sum < index.html, cat index.html | md5sum, md5sum < <(cat index.htm) and md5sum <<< "$(< index.html)" all calculates MD5 hash of the file's content. If you get different MD5 hashes for the same file downloaded multiple times, then there are differences in their content. Show some exact URLs so we can prove it to you. (Note that the .html extension does not mean the file is static. PHP or other interpreters can also parse files with .html extension, or the web server may rewrite the requested URL internally.) – manatwork Oct 6 '11 at 16:59
  • Hi manatwork. Confirmed, I was just using md5sum incorrectly. Thanks. – Julian H. Lam Oct 6 '11 at 17:18
2

Md5sum and other hashing functions have nothing to do with the timestamp of the file for which the checksum is being calculated. Unless you have some weird version installed it processes only the contents of the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.