Binary Comparison

Hi guys,

I need to write a script that will list all the files in the current diretory which are identical to a filename that the user enters using binary comparison, but I'm not entirely sure how to go about it. It's part of a larger script of system administration tools but I just can't find anything about binary comparison that's helpful.

Any advice appreciated!

Hi,

You should use md5 ( MD5: Command Line Message Digest Utility ) to do binary comparison...

I would use cmp -s to compare files and check the return code.

diff will also return for binary files, ergo:

$ diff /usr/bin/ls /usr/bin/df
Binary files /usr/bin/ls and /usr/bin/df differ
$ echo $?
2

$ diff /usr/bin/ls /usr/bin/ls
$ echo $?
0
$

Cheers, Keith