Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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

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`
    # If grep can't find the filename in that text file
    if ! egrep -q  " $EACHFILE$" md5sum.txt; then
    md5sum $EACHFILE

This assumes that the text file is like this:

964e6b94e921b5f0879b41956b787050 test.file

Which is standard output

share|improve this answer
In OSX I had to change the second line to: IFS=$'\n' – Josep Valls Sep 14 '15 at 16:47

Your Answer


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.