Can we compute hash function(sha1 and md5) for an empty directory or for directory itself in linux?

closed as unclear what you're asking by Ipor Sircer, derobert, sam, Kusalananda, Jeff Schaller Jan 4 '17 at 0:04

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Uh, what exactly is the use case? What data would the checksum operate on, in particular? – thrig Jan 3 '17 at 21:55

Sure, you can tarball the file and compute its checksum.

tar -c -O directory/ | md5sum

If you want the content checksum you can also try

find -s somedir -type f -exec md5sum {} \; | md5sum

Really depends on what you want to do...

  • no we need to compute the empty directories hash function in a particular directory. so it must be automated without help of tarballing them. – Sasank Sai Sujan Adapa Jan 3 '17 at 21:51
  • The tar solution is automated. No input necessary. You are trying to compute a hash of content in the directory? or just the directory name? – NinjaGaiden Jan 3 '17 at 21:52
  • just directory name – Sasank Sai Sujan Adapa Jan 3 '17 at 21:54
  • Try this, find directory -printf "%H\n" | md5sum – NinjaGaiden Jan 3 '17 at 21:56
  • we shouldn't modify the empty directories. But need to compute the hash function for empty directory name: for example: if we create a empty directory using touch command and then we need to compute the newly added directory's hash function which is empty. commands in linux only!! – Sasank Sai Sujan Adapa Jan 3 '17 at 21:57

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