Okay, since I plan to upload old backup archives to the cloud for fear to lose data integrity, I wanted to calculate the MD5 hash of these archives before any manipulation. OSX has natively the MD5 command provided by OpenSSL but no argument to check automatically a file checksum against another file which would contain its checksum.
And the -r generates broken MD5SUMS pattern output (the default OpenSSL star is stripped)!

In order to be able to use the md5sum command on OSX like on other Unix platforms, I developed a small script that will behave alike. I hosted it on Github and it's Open Source so you're free to contribute.

Why you shouldn't use the OSX native md5 command?

By default, the md5sum command (which is a shortcut to OpenSSL MD5 digest command I guess) outputs the following pattern: <MD5Hash (32 chars)><space><star><filename>.

The md5sum command commonly uses the star as filename delimiter (or the space if there is no star...). I don't know how it's coded behind but I got it wrong with the OSX md5 -r command. This command strips the star.

Give it a try:

# Creates a dumbass file
dd if=/dev/random of=./file bs=1m count=1
# Gets file MD5 sum with md5 command
md5 -r file
99a31dec4c3b780e220c4b80f0f41f6a file
# Gets file MD5 sum with OpenSSL command
openssl dgst -md5 -r file
99a31dec4c3b780e220c4b80f0f41f6a *file
# Counts output characters following the md5 command
md5 -r file | wc -c
# Counts output characters following the OpenSSL command
openssl dgst -md5 -r file | wc -c

Joris Berthelot