MD5 All Files In Current Dir With Progress

Here’s an example of how to md5 all the files in the current directory (with progress bar provded by pv).  there are 2 good patterns at play here.  First, the find command piped to the read command, which handles files with spaces in the name nicely.  Second, the pipe of pv to md5, which gives you a nice progress bar.  Note that the progress bar is output to stderr, so you can still write the actual md5 sum (stdout) into a file of the same name with the .md5 extension attached.  If you are using FreeBSD like I am, you will need to install the sysutils/pv port to use pv.  My codebox code highlighter is not the best, so note that line breaks should appear after (bash), (read x), (do), (md5;) and (done).

[codebox 1]

I have written this and tested it in zsh, but this should work fine in bash.  If you are using bash, all I can say is, consider testing the zsh shell on your next test machine (and in the meantime, change the first line to reflect your shell).

This works on a Mac in Terminal, but you will need the pv port (use macports or some such).


Leave a Reply




This site uses Akismet to reduce spam. Learn how your comment data is processed.