The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
diff between TAR+zip+FTP and TAR+FTP swarup2008 UNIX for Dummies Questions & Answers 1 07-02-2008 04:51 AM
diff tungaw2004 UNIX for Dummies Questions & Answers 3 04-25-2007 11:54 AM
Diff b/w $@ and $# PradeepRed Shell Programming and Scripting 4 01-24-2006 04:02 AM
diff 2 files; output diff's to 3rd file blt123 Shell Programming and Scripting 2 05-28-2002 12:29 PM
diff and ed? Brototype UNIX for Dummies Questions & Answers 2 10-29-2001 02:30 PM

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 01-19-2009
behrk2 behrk2 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 2
Question concerning DIFF

Hey,

I am running a linux shell script containing some php. I want to be able to do a DIFF on two files...if the files are identical, set an exit status of 0, and if they are different, set an exit status of 1.

I have been looking long and hard on how to do this, but I don't think that I can with DIFF. Does anyone know of any alternatives? Or anyway I can achieve this?

Here is how I am doing the DIFF:

PHP Code:
$reg_test "diff -s FILE_A FILE_B";
exec("$reg_test"); 
  #2 (permalink)  
Old 01-19-2009
glen.barber glen.barber is offline
Registered User
  
 

Join Date: May 2008
Location: Philadelphia, PA, USA
Posts: 117

Code:
diff -q file1 file2
if [ ! $? -eq 0 ]
then
  do something
else
  do something else
fi

Note: This is /bin/sh, not php. You can use this through the system() or passthru() functions.
  #3 (permalink)  
Old 01-19-2009
behrk2 behrk2 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 2
I'll give that a try, Thanks
  #4 (permalink)  
Old 01-19-2009
jpradley jpradley is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 50
On my machine, if I read the man page for diff, I see:

Exit values

Exit status is 0 for no differences, 1 for some differences, 2 for errors.

So what else do you need???
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 06:05 AM.


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