LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to find all files in folder and calculate md5 and redirect to a file in one CLI (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-all-files-in-folder-and-calculate-md5-and-redirect-to-a-file-in-one-cli-4175437407/)

chinabenjamin66 11-16-2012 04:14 AM

How to find all files in folder and calculate md5 and redirect to a file in one CLI
 
Hello friends,


Can anyone teach me how to find all files in a folder and calculate md5 hashes and redirect to a file in one command line?

Any idea will be appreciated.

druuna 11-16-2012 04:20 AM

Have a look at this:
Code:

find /path/to/files -type f -exec md5sum {} >> /path/to/outfile \;
This recursively looks for files (-type f) in /pat/to/files, creates the md5sums and stores the results in /path/to/outfile.

evo2 11-16-2012 04:20 AM

Hi,

how about
Code:

md5sum /path/to/a/folder/* > md5sums.txt

Evo2.

colucix 11-16-2012 04:21 AM

Do you mean you want to get the checksum of ALL the files inside a directory? Or do you have to specify some criteria to select some specific files? In the first case:
Code:

find /path/to/dir -maxdepth 1 -type f -exec md5sum {} \+ > all.md5
should do the trick.

Edit: too late! ;) evo2's solution is more straightforward, anyway.

evo2 11-16-2012 04:36 AM

Ohh, for completeness, the shell glob version for all files in subdirectories (or folders in OP speak)
Code:

md5sum /path/to/a/folder/**/*(^/) > md5sums.txt
Assuming of course the OP uses zsh. No need for find if you use a decent shell ;-)

Evo2.


All times are GMT -5. The time now is 09:58 AM.