[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sha1summ of complete directory?



On 2009-07-06 23:08, Scott Gifford wrote:
Ron Johnson <ron.l.johnson@cox.net> writes:

On 2009-07-06 20:29, Adrian Levi wrote:
2009/7/7 Mark Neidorff <mark@neidorff.com>:
On Monday 06 July 2009 08:30 pm, Ron Johnson wrote:
How would one go about computing a *single* hash value for a
complete directory tree?
This is what I was thinking, If you don't want to retain the tar file
then pipe it to sha1sum.
I was thinking about that, but tar stores metadata that I know are
different between the two trees, thus invalidating that idea.

You will need to figure out what metadata you care about and what you
don't, then.  For example, do you want to detect a renamed file?  A
change in mtime/ctime/utime?  A change in permissions?

For the file contents, if there are no subdirectories you can use:

    cat `ls` |sha1sum

ls will sort the files, so they will end up in the same order every
time.

For metadata, you could come up with the flags to ls that give the
metadata you want, then include that before or after the cat, like
this:

    (ls -l; cat `ls`) |sha1sum

Hope this helps,

Thanks, I *think* it did.

--
Scooty Puff, Sr
The Doom-Bringer


Reply to: