How to verify a .md5sum file in snow leopard?

In OSX, it's simply md5 or openssl md5

md5 /path/to/file

or

openssl md5 /path/to/file

Edit for clarification: You would then compare the output of the md5 command to the values in the .md5sum file to verify that the files are the same.


I see two ways for you,

  1. one is easier and means installing additional software,
  2. the other means writing a little script to automate the checksumming.

1. install GNU md5:

get macports for your system from http://www.macports.org and install the base package. Then, install the port "md5sha1sum", which has the option "-c" to read a file containing checksums and compare files to it.

or, 2. do it with what you have:

I assume you have a MD5 checksum file of the form:

0fd81f886638a12ed9efe4fd8b44187d  dir1/dir2/file4
bc2a22d0fee688065ea19e44dae88e19  dir1/file3
fa9b969a22077e46131cdd6b602a208c  dir3/file5
5c4a2bdccf48c3e7bf7489f24ac5fcb1  file1
7e06cbbb761e90e2e059657927b43f5c  file2

(note that the separator are 2 spaces)

now, create new MD5 checksums locally with openssl, like:

find * -type f | xargs openssl md5 >openssl-md5

which will produce

MD5(dir1/dir2/file4)= 0fd81f886638a12ed9efe4fd8b44187d
MD5(dir1/file3)= bc2a22d0fee688065ea19e44dae88e19
MD5(dir3/file5)= fa9b969a22077e46131cdd6b602a208c
MD5(file1)= 5c4a2bdccf48c3e7bf7489f24ac5fcb1
MD5(file2)= 7e06cbbb761e90e2e059657927b43f5c

the output is different, but you can transmogrify that to match what GNU md5 makes:

cat openssl-md5 | sed -e 's/^MD5(\(.*\))= \(.*\)/\2 \1/'

0fd81f886638a12ed9efe4fd8b44187d  dir1/dir2/file4
bc2a22d0fee688065ea19e44dae88e19  dir1/file3
fa9b969a22077e46131cdd6b602a208c  dir3/file5
5c4a2bdccf48c3e7bf7489f24ac5fcb1  file1
7e06cbbb761e90e2e059657927b43f5c  file2

this gives you a checksum file to compare to the original checksum file. Do a diff and you're finished ;-)


The solution was simply:

port install cfv

and read the manual