Check if 2 files are identical byte-to-byte? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

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

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-04-2008
krishmaths krishmaths is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 30 June 2014, 4:32 AM 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 09-04-2008
mirusnet's Avatar
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 09-04-2008
dennis.jacob's Avatar
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 02:27 AM..
    #4  
Old 09-04-2008
krishmaths krishmaths is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 30 June 2014, 4:32 AM 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 09-04-2008
dennis.jacob's Avatar
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 Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:24 PM
Given commands were created as 0 byte files dateez Emergency UNIX and Linux Support 7 03-29-2011 01:55 PM
Remove a byte(Last byte from the last line) vinayrao Shell Programming and Scripting 1 02-04-2009 05:18 PM
row count of all files with more than 0 byte sri2005 UNIX for Dummies Questions & Answers 6 04-29-2008 06:39 PM
problem with 0 byte and large files dsravan Shell Programming and Scripting 3 04-20-2007 10:59 PM



All times are GMT -4. The time now is 01:47 AM.