up vote 1 down vote favorite
share [g+] share [fb]

I have a directory containing files and an md5sum.txt file. I add a file new files to the directory. I would like add md5sum sums for all files that are not in md5sum.txt.

Is there a simple way to do it?

link|improve this question

43% accept rate
1  
What kind of script are you looking for? What operating system are you using? – innaM Nov 4 '09 at 21:35
you basically have to script reading in your md5sum.txt and directory listing and weed out from there. i'd probably choose perl for the task. – quack quixote Nov 4 '09 at 21:49
I'm using Linux. – user13798 Dec 2 '09 at 20:23
feedback

1 Answer

You can try this little number:

#We want the seperator to be newlines, not spaces
IFS="$(echo -e "\n\r")"
for EACHFILE in `ls -1`
do
    # If grep can't find the filename in that text file
    if ! egrep -q  " $EACHFILE$" md5sum.txt; then
    md5sum $EACHFILE
    fi
done

This assumes that the text file is like this:

964e6b94e921b5f0879b41956b787050 test.file

Which is standard output

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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