The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



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.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
compare files spt Shell Programming and Scripting 1 05-09-2008 11:57 AM
Compare files kharen11 UNIX for Advanced & Expert Users 25 03-14-2007 05:35 AM
Compare 2 files agustincm SUN Solaris 2 10-17-2006 12:32 AM
Compare files across 2 UNIX boxes flattyre Shell Programming and Scripting 2 09-27-2006 08:21 PM
Compare files Berserk Shell Programming and Scripting 6 09-05-2005 05:04 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-06-2007
abhishek3598 abhishek3598 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 2
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 )

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


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.

Thanks,
  #2 (permalink)  
Old 11-06-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965

Code:
#!/bin/sh

if diff fileOne fileTwo
then
       echo same
else
       echo different
fi

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0