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 md5 hashes. It's true that they're different, which diff -u a.tar.gz b.tar.gz
confirms.
What additional flags do I need to pass in to tar
so that its output is consistent over time with the same input?
tar czf outfile infiles
is equivalent toThe reason the files are different is because
gzip
puts its input filename and modification time into the compressed file. When the input is a pipe, it uses an empty string as the filename and the current time as the modification time.But it also has a
--no-name
option, which tells it not to put the name and timestamp into the file. So if you write the expanded command explicitly, instead of using the-z
option totar
, you can make use of this option.I tested this on OS X 10.6.8 and it works.