Reputation: 5742
The below is the code that makes me curious about --stdout
of the gzip
. Using the diff
command on the outputs from two different commands tells me the two files are different, but the manual check says otherwise. What's going on?
$echo "test" > tmpx
$cat tmpx | gzip > tmpx1.gz
$cat tmpx | gzip --stdout > tmpx2.gz
$diff tmpx1.gz tmpx2.gz
Binary files tmpx1.gz and tmpx2.gz differ
$zcat tmpx1.gz
test
$zcat tmpx2.gz
test
$cat tmpx1.gz
a▒U+I-.▒▒5▒;
$cat tmpx2.gz
?▒U+I-.▒▒5▒;
Upvotes: 1
Views: 349
Reputation: 112219
To add to Terrence's correct answer, there is no difference, period. When you pipe input to gzip, it automatically sends its output to stdout, whether or not you specify --stdout
.
As Terrence noted, the difference is simply in the time stamp. If you did cat tmpx | gzip > tmpx1.gz
followed by cat tmpx | gzip > tmpx2.gz
at least two seconds later, then you would see that the resulting files will differ due to the time stamp.
Upvotes: 1
Reputation: 2983
There is no difference between the compressed data.
What you are seeing is a difference in bytes 4-8 of the file. This contains a unix timestamp of when the gzip file was created.
Upvotes: 2