Operating System - HP-UX
1819805 Members
3171 Online
109607 Solutions
New Discussion юеВ

HPUX: Comparing File Systems "cmp" and "diff" commands

 
SOLVED
Go to solution
LG Porter
Frequent Advisor

HPUX: Comparing File Systems "cmp" and "diff" commands

I have a exsisting production applications that I'm copying to another shared file system. What is the best method for verifying that exsisting production files are the same as the new copy? (cp -pR /oracle/* /(new file system)) Can the "diff" and "cmp" commands be used to compare the new copy with the exsisting production file system? Does the "cp -pR" copy hidden file also?
6 REPLIES 6
Stefan Farrelly
Honored Contributor
Solution

Re: HPUX: Comparing File Systems "cmp" and "diff" commands

Create a listing of all files before and after using the sum command. This shows a checksum value to confirm absolutely that the files are the same. Then do a diff on the output before the copy, and the files after the copy. They should all have the same sum values (if some dont recopy them).
Im from Palmerston North, New Zealand, but somehow ended up in London...
Christopher McCray_1
Honored Contributor

Re: HPUX: Comparing File Systems "cmp" and "diff" commands

Hello,

You can do a ll of both old and new dirs and redirect them into different files. from there you can issue the diff command on those files.

Yes, the cp -pR does copy hidden files

Hope this helps
Chris
It wasn't me!!!!
Sajid_1
Honored Contributor

Re: HPUX: Comparing File Systems "cmp" and "diff" commands

hello,

If you can use the Mirror option, that will be the best. You don't need to worry about any of these things in that case.

You can use diff, cmp etc to compare, also check the file system space with du -k command. I would use a find with cpio to copy the files:
# find . -depth | cpio -pdlmuva /dest_dir
learn unix ..
A. Clay Stephenson
Acclaimed Contributor

Re: HPUX: Comparing File Systems "cmp" and "diff" commands

Much better than diff or cmp is the cksum command. It does a CRC checksum on the files. If they match, you are absolutely assured that the files are identical in content. Man cksum for details. If by 'hidden' files, you mean do cp -pR * copy files that begin with '.' then no it does not but that is really determined by the arguments passed into the command from the shell.


If it ain't broke, I can fix that.
Hai Nguyen_1
Honored Contributor

Re: HPUX: Comparing File Systems "cmp" and "diff" commands

LG Porter,

diff is used to compare text files. while cmp is for comparing binary files.

In your case, dircmp may be useful, which is used to compare two directories.

Hai
S.K. Chan
Honored Contributor

Re: HPUX: Comparing File Systems "cmp" and "diff" commands

The "cksum" command is the prefered way (for me). Simply .. (eg : if filea and fileb are identical)
# cksum filea fileb
=> will return similar output in the 1st and 2nd field.