Unix/Linux Go Back    

UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

UNIX; Compare two files

UNIX for Advanced & Expert Users

Thread Tools Search this Thread Display Modes
Old Unix and Linux 11-06-2007
abhishek3598 abhishek3598 is offline
Registered User
Join Date: Nov 2007
Last Activity: 9 November 2007, 4:56 PM EST
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
UNIX; Compare two files

Hi Guys,

Requirement: Want to compare two files, if the the content of both files is same then show "Good result" else Show "Bad Result"[/B][/B]

I am using the following logic
if( cmp -s a b = 0 )

echo "Good result"
else echo "Bad result"
exit 0

But this is not working. FYI, the content of file is as shown below

Content of file a

0 TOTALS 8,325 17,887,904 13,907 163,243,465 1,306,821,707 10.9 %

Of file b
0 TOTALS 8,325 10,000,904 13,907 163,243,465 1,306,821,707 10.9 %

Since the 4th values in b is differnt so that output of If statement should be "Bad result"

It will be really great if someone can help me out with this.

Sponsored Links
Old Unix and Linux 11-06-2007
porter porter is offline Forum Advisor  
Registered User
Join Date: Jan 2007
Last Activity: 8 January 2008, 6:50 PM EST
Posts: 2,965
Thanks: 0
Thanked 5 Times in 5 Posts


if diff fileOne fileTwo
       echo same
       echo different

Sponsored Links

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
Compare two files in UNIX forums123456 Shell Programming and Scripting 4 08-02-2011 09:21 PM
How to compare two files using UNIX? gpsridhar UNIX for Advanced & Expert Users 6 10-22-2010 03:19 AM
how can i unix compare two files?? nirnir26 UNIX for Dummies Questions & Answers 2 11-19-2009 06:52 AM
Unix Compare Files Lagre1 UNIX for Dummies Questions & Answers 2 12-11-2008 01:19 PM
how to compare all files in one unix box has been to copied to another unix box sravanreddym Shell Programming and Scripting 9 07-03-2008 11:43 AM

All times are GMT -4. The time now is 12:25 AM.