How can I match md5 hashes with the grep command?
In php I used this regular expression pattern in the past:
/^[0-9a-f]{32}$/i
But I t
A little one-liner which works cross platform on Linux and OSX, only returning the MD5 hash value (replace YOURFILE
with your filename):
[ "$(uname)" = "Darwin" ] && { MD5CMD=md5; } || { MD5CMD=md5sum; } \
&& { ${MD5CMD} YOURFILE | grep -o "[a-fA-F0-9]\{32\}"; }
Example:
$ touch YOURFILE
$ [ "$(uname)" = "Darwin" ] && { MD5CMD=md5; } || { MD5CMD=md5sum; } && { ${MD5CMD} YOURFILE | grep -o "[a-fA-F0-9]\{32\}"; }
d41d8cd98f00b204e9800998ecf8427e