Why are different md5 hashes from two archives of the same file different?
I can run:
echo "asdf" > testfile tar czf a.tar.gz testfile tar czf b.tar.gz testfile md5sum *.tar.gz and it turns out that a.tar.gz and b.tar.gz have different xd5 hashes. It is true that they are different, which is confirmed by diff -u a.tar.gz b.tar.gz
What additional flags do I need to pass to tar so that its output is consistent in time with the same input?
tar czf outfile infiles equivalent
tar cf - infiles | gzip > outfile The reason the files are different is because gzip puts its input file name and modification time in a compressed file. When the input is a channel, it uses an empty string as the file name and current time as the modification time.
But it also has a parameter --no-name , which tells it not to put the name and timestamp in the file. Therefore, if you explicitly write an extended command, instead of using the -z option on tar , you can use this option.
tar cf - testfile | gzip --no-name > a.tar.gz tar cf - testfile | gzip --no-name > b.tar.gz I tested this on OS X 10.6.8 and it works.