Operating System - HP-UX
1844837 Members
3055 Online
110233 Solutions
New Discussion

Compare contents of two files

 
SOLVED
Go to solution
Miguel Carabano_1
Regular Advisor

Compare contents of two files

Hi,

What is the command to compare contents of two files,
example:
I need compare two kernels.

Thanks
14 REPLIES 14
Pete Randall
Outstanding Contributor

Re: Compare contents of two files

cmp

as in "cmp file1 file2"


Pete

Pete
baiju_3
Esteemed Contributor
Solution

Re: Compare contents of two files

man cmp .
man diff.

Rgards ,
bl.
Good things Just Got better (Plz,not stolen from advertisement -:) )
Chan 007
Honored Contributor

Re: Compare contents of two files

Hi

use

diff

if you wanted to know if they are one and same, then use

cksum - if both has similar output numbers the files are identical

Chan
James R. Ferguson
Acclaimed Contributor

Re: Compare contents of two files

Hi Miquel:

While 'diff' and 'cmp' will compare and optionally report the differences of ASSCII text files, all that will be returned for binary files is whether they differ or not.

If two binary files differ, 'diff' will simply note:

"Binary files f1 and f2 differ"

The best way to valid the "sameness" of any two files is to compare their 'cksum' value:

# cksum /stand/vmunix
2335558063 10340004 /stand/vmunix

The first number is the computed cksum; teh second is the number of octets.

Regards!

...JRF...
Paul Sperry
Honored Contributor

Re: Compare contents of two files

diff file1 file2
Miguel Carabano_1
Regular Advisor

Re: Compare contents of two files

Hi,

I need compare the output of kmtune and to know as they are the differences.

Then aplly the changes...

MC
Indrajit_1
Valued Contributor

Re: Compare contents of two files

Hi;

Try the following command..

#cmp file1_nmae file2_name

cheers
indrajit
Never Ever Give Up
James R. Ferguson
Acclaimed Contributor

Re: Compare contents of two files

Hi Miquel:

On each server, do:

# kmtune -l > /tmp/kmtune.$(hostnmae)

Then:

# diff -bC1 /tmp/kmtune.host1 /tmp/kmtune.host2

...to show lines in context...or simply:

# diff /tmp/kmtune.host1 /tmp/kmtune.host2

See the manpages for 'diff' for more information.

Regards!

...JRF...

Deoncia Grayson_1
Honored Contributor

Re: Compare contents of two files

diff /stand/system /stand/build/system to see any changes you have made, but next time just use Sam to make kernel changes that way you can see the current value and the pending value before you reboot your server
If no one ever took risks, Michelangelo would have painted the Sistine floor. -Neil Simon
Nguyen Anh Tien
Honored Contributor

Re: Compare contents of two files

On HP-UX you can use:
#diff file1 file2
tienna
HP is simple
Muthukumar_5
Honored Contributor

Re: Compare contents of two files

Try as,

nm /stand/vmunix > /tmp/kernel1.symbol
nm > /tmp/kernel2.symbol
diff /tmp/kernel1.symbol /tmp/kernel2.symbol

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

Re: Compare contents of two files

Another way as,

strings /stand/vmunix > /tmp/kernel1
strings > /tmp/kernel2
diff /tmp/kernel1 /tmp/kernel2

--
Muthu
Easy to suggest when don't know about the problem!
Cem Tugrul
Esteemed Contributor

Re: Compare contents of two files

Hello,
cmp and diff would be a solution for you
cmp file1 file2
diff file1 file2
Good Luck,
Our greatest duty in this life is to help others. And please, if you can't
Miguel Carabano_1
Regular Advisor

Re: Compare contents of two files

Thanks.

MC