Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using diff on non-text files
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
GetCool
Guru
Guru


Joined: 23 Nov 2003
Posts: 324
Location: Madison, Wisconsin

PostPosted: Sun Apr 30, 2006 11:27 pm    Post subject: Using diff on non-text files Reply with quote

I've always used diff to compare the contents of text files, but I'm wondering if it can also be used to accurately compare other kinds of files (as in an alternative measure to using md5sum).

I know I can do:

Code:
# diff -r /dir1 /dir2


...to compare two directories recursively, but if I want to know if these two directories are identical, would the above command be as accurate as if I ran md5sum recursively on all of the contents and compared the lists of checksums?
Back to top
View user's profile Send private message
didymos
Advocate
Advocate


Joined: 10 Oct 2005
Posts: 4798
Location: California

PostPosted: Mon May 01, 2006 10:55 pm    Post subject: Reply with quote

I'm not sure about md5sum, but you can do a byte by byte comparison of two files with the cmp command. Diff on
binary files just tells you if they differ, not how. If you specify the --text option, it will treat the files as text, and ouptut all
sorts of nifty stuff to the terminal. The most pager works well with binary output, if you want to examine the diff visually.
_________________
Thomas S. Howard
Back to top
View user's profile Send private message
GetCool
Guru
Guru


Joined: 23 Nov 2003
Posts: 324
Location: Madison, Wisconsin

PostPosted: Tue May 02, 2006 1:10 am    Post subject: Reply with quote

didymos wrote:
I'm not sure about md5sum, but you can do a byte by byte comparison of two files with the cmp command. Diff on
binary files just tells you if they differ, not how. If you specify the --text option, it will treat the files as text, and ouptut all
sorts of nifty stuff to the terminal. The most pager works well with binary output, if you want to examine the diff visually.


Thanks for the info.

I really just want to know if the contents of two directories are identical or not after a copy; I don't necessarily need to see the differences. Since cmp doesn't seem to have a recursive option, I've been trying diff, which seems to work, but I just want to make sure that it's really doing an accurate comparison.

Of course, anything can be scripted to recursively scan a directory and look at all of the contents, but I'd rather just issue a single command to do it. And if I was going to write a script I'd use md5sum.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum