Recursive MD5 Sum Script
This week I made this shell script to search one level deep and MD5 all of the files. I did this because I had multiple images and I wanted to see what images were the same so that I could merge them together. Its a pretty simple script & the output is the same as md5suming a file except there is more than one sum generated.
#MD5 Files in the directories md5Dir () { echo $directory; for x in $(ls -1 $directory); do md5sum $directory'/'$x; done; } #Lists The Directories for i in $(ls | grep active); do directory=$i; md5Dir; done; |
It only does one level deep but thats good enough for now. I am going to make it search recursively depending on the levels given by the user. I would also like to make it display files that are the same at the end.
It gets the job done for small directories, but if I wanted to run it on large multiple directories with lots of files in them I would definitely redirect the output to a file because it can be quite overwhelming. To run it just copy the code into a file and do the following:
sh [filename] |
I hope this helps some one who is trying to MD5 multiple files in different directories!