1

i need to calculate a checksum for a directory in question.

It should return one number for this directory, not for each file inside it.

Can you, quys, help me with it ?

Thanks.

6
  • 1
    What are you trying to checksum? The directory information (filenames, inode numbers), or also the file meta information (modification times etc) or also the file contents or what? Under what circumstances do you expect the directory to have a different checksum? Oct 21, 2010 at 11:15
  • 1
    Calculate checksums for each file, for the metadata and XOR it all. Do this recursively if necessary.
    – Fred Foo
    Oct 21, 2010 at 11:16
  • @Paul, i need to make sure, that nobody has changed the files in a directory in question.
    – AntonAL
    Oct 21, 2010 at 11:23
  • 1
    Then just checksum each file and sum the results? Does your definition of "changed the files" include changes to permissions, creation/modification dates, owner/group etc? Oct 21, 2010 at 11:29
  • Yes. I think, i can also just take a sum of all the results. I'm playing with the "cat" command, but, no success right now. I say following: "find ./crc_test/ -type f | cat | crc32", but i does't work.
    – AntonAL
    Oct 21, 2010 at 11:37

2 Answers 2

2

You may be able to use tar to do this. Something like tar -c dir/ | md5sum -b, although you may need to play with the options to tar so it doesn't include access times (which would mess up the checksum if somebody accesses the files in that directory, even without modifying any of them).

1

Check out md5deep. From its homepage:

md5deep is a set of programs to compute MD5, SHA-1, SHA-256, Tiger, or Whirlpool message digests on an arbitrary number of files.

I haven't used it myself, but from what I gather it's pretty much a collection of multi-file versions of md5sum, sha256sum and similar checksum tools from GNU Coreutils.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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