I did thought the following commands where equivalent, but they produce different checksums:
tar -cvzf ...
and tar -cvf ...; gzip ...
does not produce the same output.
sha1sum
differs.
What would be the gzip
command that would perfectly match the tar -cvzf
behavior?
The difference in the output files is probably NOT due to the compression method. By default GNU tar uses the standard GZIP deflate mode. One reason for the difference is in the format of GZIP compressed file.
The structure of the first 8 bytes of the GZIP header is as follows
The problem is with the
MTIME
field. For data that comes from a pipe this is the value of the current Unix time (seconds since Jan 1, 1970). Therefore two otherwise identical compressed archives created with at least one second interval from each other will be different.Try to run
tar -cvzf
twice on the same data and compare the results. The results will differ in the 5th byte, the lowest byte of the timestamp value.