Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm searching for a script which creates a md5 chechsum file for every single folder inside drive recursivley?

I do have a copy of md5deep on my machine but I'm not that good in scripting bash.

share|improve this question
3  
Why do you need a script if you have md5deep, why not just md5deep -r [folder name]? –  Random832 Aug 30 '12 at 13:24
1  
Because md5deep creates one file with all checksums. What I want is a md5-file for every single file. For Example: document1.doc document1.md5, document2.doc document2.md5 and so on. –  tristank Aug 30 '12 at 13:37
    
That's an unusual thing to want - most people go with either one file with all checksums, or one file per directory with all the files in that directory. –  Random832 Aug 30 '12 at 13:38
    
So it's not possible? –  tristank Aug 30 '12 at 13:40
    
Similair to what integritychecker on mac os x does: diglloydtools.com/integritychecker.html –  tristank Aug 30 '12 at 13:42
show 3 more comments

1 Answer 1

To get a .md5 file for any files under a specific directory, you can use the following script:

#!/bin/bash
if [ $# -ne 1 ] ; then
        echo "Usage $0 [directory]" 
        exit 1
fi
find $1 -type f  -print0 | while IFS= read -r -d $'\0' file; do
    (
    cd "$(dirname "$file")"
    filename="$(basename "$file")"
    md5sum "$filename" > "$filename".md5
    )
done

In zsh, the same for all files under the current directory can be done with the one-line command (includes files starting with a dot):

for i in **/*(/D) ; do ( cd $i ; for j in *(.D) ; do md5sum $j > $j.md5 ; done ) ; done 
share|improve this answer
    
@la_tristesse I rewrote my answer. Please be more specific in your questions in the future. –  jofel Aug 30 '12 at 14:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.