Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Check if 2 files are identical byte-to-byte?

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 09-04-2008
krishmaths krishmaths is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 26 March 2015, 1:39 PM EDT
Location: Chennai, India
Posts: 443
Thanks: 22
Thanked 70 Times in 68 Posts
Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server.

For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match.

Please help.
Sponsored Links
    #2  
Old Unix and Linux 09-04-2008
mirusnet's Unix or Linux Image
mirusnet mirusnet is offline
Registered User
 
Join Date: Dec 2007
Last Activity: 18 June 2010, 4:33 AM EDT
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts

Code:
md5 $file

Sponsored Links
    #3  
Old Unix and Linux 09-04-2008
dennis.jacob's Unix or Linux Image
dennis.jacob dennis.jacob is offline Forum Advisor  
Registered User
 
Join Date: Feb 2007
Last Activity: 30 March 2014, 9:33 AM EDT
Location: Singapore/Cochin
Posts: 871
Thanks: 0
Thanked 12 Times in 11 Posts
Quote:
Originally Posted by krishmaths View Post
In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server.

For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match.

Please help.
Why can't you try doing a cksum on both files and compare?

Last edited by dennis.jacob; 09-04-2008 at 01:27 AM..
    #4  
Old Unix and Linux 09-04-2008
krishmaths krishmaths is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 26 March 2015, 1:39 PM EDT
Location: Chennai, India
Posts: 443
Thanks: 22
Thanked 70 Times in 68 Posts
cksum works fine. I tried on test files. Thanks dj.

Just curious to know if there are any more methods.
Sponsored Links
    #5  
Old Unix and Linux 09-04-2008
dennis.jacob's Unix or Linux Image
dennis.jacob dennis.jacob is offline Forum Advisor  
Registered User
 
Join Date: Feb 2007
Last Activity: 30 March 2014, 9:33 AM EDT
Location: Singapore/Cochin
Posts: 871
Thanks: 0
Thanked 12 Times in 11 Posts
Quote:
Originally Posted by krishmaths View Post
cksum works fine. I tried on test files. Thanks dj.

Just curious to know if there are any more methods.

Code:
cmp -l file1 file2

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Exit status as zero byte files genehunter UNIX for Dummies Questions & Answers 1 05-10-2012 12:24 PM
Given commands were created as 0 byte files dateez Emergency UNIX and Linux Support 7 03-29-2011 12:55 PM
Remove a byte(Last byte from the last line) vinayrao Shell Programming and Scripting 1 02-04-2009 04:18 PM
row count of all files with more than 0 byte sri2005 UNIX for Dummies Questions & Answers 6 04-29-2008 05:39 PM
problem with 0 byte and large files dsravan Shell Programming and Scripting 3 04-20-2007 09:59 PM



All times are GMT -4. The time now is 11:16 AM.