Saya menulis tes unit untuk beberapa kode dan menemukan itu sederhana gzip menyebabkan perbedaan dalam hasil saya. Setelah diselidiki lebih lanjut, saya menemukannya gzip memberi yang berbeda .gz file dari gzip -c tidak. Kenapa ini?
$ echo "foo" > bar
$ gzip bar
$ zcat bar.gz | gzip -c > test.gz
$ cmp bar.gz test.gz
bar.gz test.gz differ: byte 4, line 1
$ stat bar.gz | grep Size
Size: 28 Blocks: 0 IO Block: 4194304 regular file
$ stat test.gz | grep Size
Size: 24 Blocks: 0 IO Block: 4194304 regular file
$ zcat bar.gz > foo1.txt
$ zcat test.gz > foo2.txt
$ cmp foo1.txt foo2.txt
$ echo $?
0
-copsi jika Anda mengirim kegzip. man gzip :If no files are specified, or if a file name is "-", the standard input is compressed to the standard output.