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

Re: sha1summ of complete directory?



Tzafrir Cohen <tzafrir@cohens.org.il> writes:

> On Tue, Jul 07, 2009 at 12:08:05AM -0400, Scott Gifford wrote:

[...]

>> For the file contents, if there are no subdirectories you can use:
>> 
>>     cat `ls` |sha1sum
>
> Which is basically:
>
>   cat * | sha1sum

The purpose of the ls was to sort the filenames, but looking more
clostey, bash sorts them already.  csh and ksh do the same, and
glob(3) sorts by default.  I'm not sure if all shells do that or not,
but it seems that most do, and if your shell does, those two should be
equivalent.

Thanks Tzafrir, I learned something today!  :-)

[...]

> Also note that packing files together with their metadata is, in fact,
> exactly what an archive utility does:
>
>   tar cf - . | sha1sum
>
> This will also pick hidden files and subdirectories.

If there were a way to specify what metadata to include in the
archive, this would be a perfect solution for the OP.

----Scott.


Reply to: