- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Verify two files are exactly equal eachother.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 10:31 AM
01-24-2008 10:31 AM
Verify two files are exactly equal eachother.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 10:33 AM
01-24-2008 10:33 AM
Re: Verify two files are exactly equal eachother.
diff file1 file2
man diff for details.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 10:37 AM
01-24-2008 10:37 AM
Re: Verify two files are exactly equal eachother.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 10:37 AM
01-24-2008 10:37 AM
Re: Verify two files are exactly equal eachother.
sum filea fileb
cksum filea fileb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 10:38 AM
01-24-2008 10:38 AM
Re: Verify two files are exactly equal eachother.
cksum -- cksum is typically used to verify data integrity when copying files between systems.
Regards,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 11:06 AM
01-24-2008 11:06 AM
Re: Verify two files are exactly equal eachother.
As noted, 'diff' for ASCII (text) files. For binary files you can use 'cksum' or for a bigger, better hammer, use 'md5'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 11:19 AM
01-24-2008 11:19 AM
Re: Verify two files are exactly equal eachother.
Why 'risk' a false positive from a checksum?
For files on different systems, perhaps even with a different platform, a checksum tool like cksum or md5 is appropriate.
Food for thought: When is the last time you, or anyone out here ever saw a file being different after a succesful copy?
I appreciate the 'check and double-check' attitude, but in reality a simple byte-count (ls -l) will probably catch 99.9999% of the cases. My advice? Don't bother!
And if you wanted to check seriously then you must make sure that the (OS) and controller caches are flushed because a compare against recently copied files might not read anything from the disk itself, relying on cached data. So if it misteriously was read wrong the first time, then the second time the same wrong data could be used.
Enjoy!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 11:27 AM
01-24-2008 11:27 AM
Re: Verify two files are exactly equal eachother.
Re: last time I saw...
On an Intel box? Often enough to worry about it.
On an HP box? Can't even remember a case...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 12:14 PM
01-24-2008 12:14 PM
Re: Verify two files are exactly equal eachother.
> Hein: If the files are available from a single system, then 'diff'...Binary files as well as text files.
Ah, thanks, I never remember that 'diff' doesn't care.
> Hein: Why 'risk' a false positive from a checksum?
While I would consider that very unlikely, that's why I suggested 'md5sum'.
> Hein: For files on different systems, perhaps even with a different platform, a checksum tool like cksum or md5 is appropriate.
This assumes that the systems share a common newline indication for text files. If the end-of-line characters are different (e.g. UNIX vs. Windows or MAC: \012 versus \015\012 versus \015, respectively) then this is going to alter the results.
> Hein: And if you wanted to check seriously then you must make sure that the (OS) and controller caches are flushed...
Hmmm. that is interesting.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 02:30 PM
01-24-2008 02:30 PM
Re: Verify two files are exactly equal eachother.
> use cksum
If you care only _whether_ they're different,
but not about what the differences are, then
"cmp" can be much nicer than plain "diff".
"cmp" appears to quit when it finds the first
difference, while "diff" can waste a lot of
time processing (large) different files.
Similarly, a checksum calculation always
requires reading all of each file.
Also, a lame "diff" program can require you
to use "> /dev/null" to avoid confusing your
terminal when dealing with non-text files.
> When is the last time you, or anyone out
> here ever saw a file being different after
> a succesful copy?
It's not very hard to get a partial FTP or
HTTP download which fails with no symptom
other than a corrupt (partial) file.
Sometimes it's the server's problem,
sometimes the client's.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2008 03:26 PM
01-24-2008 03:26 PM
Re: Verify two files are exactly equal eachother.
Steven wrote> "cmp" appears to quit when it finds the first difference, while "diff" can waste
Ah! Thanks for that.
This is why I keep reading even seemingly trivial questions.
Someone might point out a new solution, or at least remind me of long since forgotten alternatives.
Hein> ever saw a file being different after a succesful copy?
Steven> It's not very hard to get a partial FTP or
That's why I wrote copy, not transfer.
And I suppose copies with NFS involved are a little suspect also.
it's all too easy to get
Hein> (OS) and controller caches are flushed...
JRF> Hmmm. that is interesting.
Well, for a good sized file (1GB or more) the tails of the files with chase the heads out of the caches. But file of even a few 100 MBs might just fit in the cache, unless the cache is trained to recoginize long sequential IO patterns (iirc the Tru64 UBC special cased this).
So you really want to at least issue 'sync' before a compare. The sync might actually trigger a report for IO errors for a long since (30 seconds :-) completed copy.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 02:23 AM
01-25-2008 02:23 AM
Re: Verify two files are exactly equal eachother.
As Hein says, you can also use diff(1) but you'll need to suppress the nasty warning when different.
For Steven's cmp(1), you'll want to use -s to suppress the output.
>Hein: [Dang, have to re-enter.
With firefox, just go back and resubmit.