If and Or Condition in Unix [ksh] | 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.

If and Or Condition in Unix [ksh]

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-03-2006
leemjesse leemjesse is offline
Registered User
 
Join Date: Mar 2005
Last Activity: 29 April 2013, 9:45 AM EDT
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
If and Or Condition in Unix [ksh]

I have the code below. I want to said

If TrackErrors > 0 or count == 0
then
MailErrors
else
MailSuccess
fi.

if [ ${trackErrors} -gt 0 || ${count} -eq 0 ]
then
MailErrors ${count}
else
MailSuccess ${count}
fi

Any helps greatly appreciated.
Sponsored Links
    #2  
Old 01-03-2006
leemjesse leemjesse is offline
Registered User
 
Join Date: Mar 2005
Last Activity: 29 April 2013, 9:45 AM EDT
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
I figured out. I hope this will benefit others.

if [ ${trackErrors} -gt 0 -o ${count} -eq 0 ]
then
MailErrors ${count}
else
MailSuccess ${count}
fi
Sponsored Links
    #3  
Old 01-03-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
 
Join Date: Jan 2005
Last Activity: 27 September 2011, 12:36 PM EDT
Posts: 683
Thanks: 0
Thanked 4 Times in 4 Posts
Quote:
Originally Posted by leemjesse

Code:
if [ ${trackErrors} -gt 0  || ${count} -eq 0 ]
then
  MailErrors ${count}
else
  MailSuccess ${count}
fi

You can change your original structure as well by doubling the brackets:

Code:
if [[ ${trackErrors} -gt 0  || ${count} -eq 0 ]]
then
  MailErrors ${count}
else
  MailSuccess ${count}
fi

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
Unix and db2 where condition issue(new line) msp2244 Shell Programming and Scripting 1 02-22-2012 05:03 PM
redirect stdout echo command in condition A run in condition B jao_madn Shell Programming and Scripting 3 11-02-2011 09:01 PM
In unix how we can test or check race condition in a c program by using multi threads afroze Programming 1 03-05-2009 05:22 AM
In unix how we can test or check race condition in c program by using multi threads afroze Linux 1 02-24-2009 10:34 AM
if...elif...fi condition in Unix abidmalik UNIX for Dummies Questions & Answers 9 09-05-2002 08:35 AM



All times are GMT -4. The time now is 07:36 PM.