1844086 Members
2983 Online
110227 Solutions
New Discussion

Re: cmp command !!!

 
SOLVED
Go to solution
Manuales
Super Advisor

cmp command !!!

I'm making some tests of restoring some files from omniback.

i wish compare both files, the file restored and file living in the path.
How can i compare them?
can i use diff command?
can i use cmp command?

How can i use cmp command ?

Thanks, Manuales.
11 REPLIES 11
Steven E. Protter
Exalted Contributor
Solution

Re: cmp command !!!

Shalom,

I know for ascii files you can use the diff command.

For an alternative.

http://www.thefreecountry.com/programming/filecomparison.shtml

The diff command may have a binary switch, but I can't remember right now. See the man page for my memory gap.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
A. Clay Stephenson
Acclaimed Contributor

Re: cmp command !!!

The best possible comparison is the cksum command; it will work on files of any type. If the CRC cksums are equal, the files are exactly the same.
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: cmp command !!!

Hi Manuales:

As Clay noted, a definitive file comparison test is the 'cksum' command. You can compare binary or ASCII files in this manner.

Compare the checksums of the files in the corresponding directories to determine if the contents of two directories are the same.

Blocks are be allocated to a directory as files are added, but the blocks are not returned when files are deleted. Thus you will often see a replicated directory's size smaller than its source directory. This is of no concern if the checksums of the *contents* of the two directories match.

'diff' and 'bdiff' can examine directories recursively, if both arguments are directories. 'diff' then sorts the contents of the directories by name, and runs on *text* files that have the same name in each directory.

See the manpages for more information.

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: cmp command !!!

Hi (again) Manuales:

I should not have suggested that 'diff' will not compare binary files. It will. Instead of reporting the differences as it does with ASCII files, it will report, for example:

"Binary files /tmp/file1 and /tmp/file2 differ"

Using 'cksum' one can compare the computed value of the two files for equality.

/No_Points Please For This Clarification/

Regards!

...JRF...
Raj D.
Honored Contributor

Re: cmp command !!!

Manuales ,

Check with cksum, it gives best result, to check and compare two file. The checksum value should be same for both the case.

furthre # man cksum


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Muthukumar_5
Honored Contributor

Re: cmp command !!!

It is not good to use diff or cmp commands with all files. It cannot compare on binary files.

Try to use cksum command to get difference.

cksum file1 file2

will give the details.

--
Muthu
Easy to suggest when don't know about the problem!
Arunvijai_4
Honored Contributor

Re: cmp command !!!

Hi Manuales,

You can use "cksum" suggested by unix gurus here. As well, if you want to have a try with something else, look at md5cksum.

http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=md5checksum

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Manuales
Super Advisor

Re: cmp command !!!

Hi, i have already executed next:
# cksum log_g13m1.dbf log_g13m1.dbf.back
2219005271 52429824 log_g13m1.dbf
3688632956 52429824 log_g13m1.dbf.back

my doubt now is:
what is the meanning of first and second field?

Manuales.
Arunvijai_4
Honored Contributor

Re: cmp command !!!

Hi Manuales,

First field is the check sum value and second field is size of the file.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Pete Randall
Outstanding Contributor

Re: cmp command !!!

The first number is the CRC and the second is the size of the file in bytes.


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: cmp command !!!

If you had simply bothered to do a "man cksum", you would have your answer.
If it ain't broke, I can fix that.