Skip to content

OS X md5sum Hack

I found this nifty little shell script that roughly duplicates the md5sum command on OS X. The problem is, it doesn’t work anymore, something about the syntax for the expr command being invalid.

Anywho, I modified it like so:

#!/usr/bin/env bash
output=`md5 "$1"`
echo `echo $output | sed -e 's/MD5 (\(.*\)) = \(.*\)/\2  \1/'`

I’m sure the openssl md5 command would work still as well as the md5 command. They both output something similar to:

MD5 (my_file.txt) = caff1120584b95432eed1e84cb99a593

That’s where the sed thing comes in handy, to convert it to:

caff1120584b95432eed1e84cb99a593  my_file.txt

Posted in Bash, OS X, Tips and Tricks.

One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Dave says

    Sweet! If I could just get “md5sum -c file.md5” to check a bunch of files. Now I’m getting greedy. 🙂

Some HTML is OK

or, reply to this post via trackback.