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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
please explain the below mail2sant Shell Programming and Scripting 1 04-04-2008 05:04 AM
Please can any one explain this ${0##/} gadege Shell Programming and Scripting 2 04-01-2008 12:26 PM
please explain this dummy_needhelp Shell Programming and Scripting 2 10-14-2007 10:17 PM
Can anyone explain plz r_W213 UNIX for Advanced & Expert Users 3 03-27-2007 01:52 AM
Explain awk hitmansilentass Shell Programming and Scripting 4 09-27-2006 11:14 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-03-2006
Registered User
 

Join Date: Aug 2006
Posts: 5
Stumble this Post!
Question if [ $? -eq 0 ] .. can someone explain this?

I thought it means if the return code of the previous command not equal to 0...
Is this correct?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-03-2006
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
you are correct
Reply With Quote
  #3 (permalink)  
Old 10-03-2006
Registered User
 

Join Date: Jul 2006
Posts: 183
Stumble this Post!
No it's not "not equal" but "equal"
Reply With Quote
  #4 (permalink)  
Old 10-03-2006
Registered User
 

Join Date: Sep 2002
Posts: 12
Stumble this Post!
Quote:
Originally Posted by dsravan
No it's not "not equal" but "equal"

`-eg` = equal
Reply With Quote
  #5 (permalink)  
Old 10-03-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,002
Stumble this Post!
Quote:
Originally Posted by ranjita.c
I thought it means if the return code of the previous command not equal to 0...
Is this correct?
I'd interprete this as 'not equal to 0' which is to say '-ne 0'.
Reply With Quote
  #6 (permalink)  
Old 10-03-2006
Registered User
 

Join Date: Feb 2005
Location: Broomfield, CO
Posts: 395
Stumble this Post!
The numeric comparisons for korn shell are

numA -eq numB - True if numA and numB are equal
numA -ne numB - True if numA and numB are not equal
numA -lt numB - True if numA is less than numB
numA -gt numB - True if numA is greater than numB
numA -le numB - True if numA is less than or equal to numB
numA -ge numB - True if numA is greater than or equal to numB

the string comparisons for korn shell are

strA = strB - True if strA matches strB
strA != strB - True if strA does not match strB
strA < strB - True if strA comes before strB in a dictionary order
strA > strB - True if strA comes after strB in a dictionary order

So your example says to run the commands between then and fi or else if the return code of the previous command is equal to zero (0).

Carl
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0