recursive md5 hashing with Linux

The problem: You need a md5sum of a directory. Unfortunately, md5sum just accepts files as input.

The solution: Let’s use find! Okay. Here we go:

find DIRECTORY -type f -exec md5sum ‘{}’ \; | md5sum – | awk ‘{print $1}’

explanation:

-type f

just shows files

-exec

run the following command

‘{}’

find’s results to hand over to the command

\;

tell -exec that end of command has been reached

| md5sum -

hand over the results of the first md5sum (one sum for each file) to another

| awk ‘{print $1}’

beautify the output as we just want to have the md5sum. nothing more, nothing less.

 

This entry was posted in howto, Linux. Bookmark the permalink.

One Response to recursive md5 hashing with Linux

  1. Pingback: New MD5 based backup script « jbmurphy.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>