Why does diff differ?

Joined
Jan 26, 2010
Messages
7
Reaction score
0
Points
1
I retrieved the same gzip file, once as file1.gz, the second as file2.gz.
When I diff file1.gz with file2.gz I get the message binary files differ.
If I ungzip file1.gz and diff it to the ungzip of file2.gz they are the same. (No difference)

The only hint, or possibly wild goose chase I seem to have, is that retrieval process did a move, in that if I do a file on file1.gz and file2.gz I see

bash-3.2$ file /tmp/1.gz
/tmp/1.gz: gzip compressed data, was "eenfIAAa11931", from Unix, last modified: Wed Aug 25 07:11:26 2010
bash-3.2$ file /tmp/2.gz
/tmp/2.gz: gzip compressed data, was "eenfZAAa09151", from Unix, last modified: Wed Aug 25 07:13:03 2010

Is some sort of Meta data getting in the way of diff? Why does it differ?

Any thoughts would be appreciated.
John
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,771
Reaction score
2,110
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
First, diff is only meant for text file comparison. Second, you're checking the files in an incorrect manner..

For example
Code:
# dd if=/dev/urandom of=file1 bs=1024k count=1
l1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.207587 s, 5.1 MB/s

#md5sum file1
18eff184e1697043bfed478f787e18ff  file1

# cp file1 file2
# ls
file1 file2

# md5sum file*
18eff184e1697043bfed478f787e18ff  file1
18eff184e1697043bfed478f787e18ff  file2

# gzip file1; gzip file2
# ls
file1.gz file2.gz

# diff file1.gz file2.gz 
Binary files file1.gz and file2.gz differ

#  md5sum file*
4dea0f01ec2c62e3497a7a268d06fcf3  file1.gz
65ab5a30cfadbb5e70295c61000b34ff  file2.gz

# gunzip *
# ls
file1 file2

# md5sum *
18eff184e1697043bfed478f787e18ff  file1
18eff184e1697043bfed478f787e18ff  file2
# diff file1 file2

So the gzipped files are different based on their md5sums, but what matters is the uncompressed content is the exact same..

Regards
 
OP
Z
Joined
Jan 26, 2010
Messages
7
Reaction score
0
Points
1
Thanks for the reply. I tried your example as well. It behaves as you say. I believed some how OSX was behaving differently than Linux, but it is the same there as well.

I really thought it was the same and I now understand why.

Thanks for your help. I'm very appreciative.

John
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top