Shell Programming and Scripting

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

If statement - How to write a null statement

👤 Login to reply

    #1  
Old 04-16-2008
april april is offline
Registered User
 
If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands.

How do I write the "do nothing" statement in the following example?

Example:

if (( "$x"="1" && "$y"="a" && "$z"="happy" ))
then
do nothing
else
command
command
fi

Thanks.
Sponsored Links
    #2  
Old 04-16-2008
aigles's Unix or Linux Image
aigles aigles is offline Forum Advisor  
Registered User
 
Code:
if (( "$x"="1" && "$y"="a" && "$z"="happy" ))
then
   :
else
   command
   command
fi

Another way, invert your test :
Code:
if (( "$x"!="1" || "$y"!="a" || "$z"!="happy" ))
then
   command
   command
fi


Jean-Pierre.
Sponsored Links
    #3  
Old 04-16-2008
vgersh99's Unix or Linux Image
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
 
Code:
if (( "$x"="1" && "$y"="a" && "$z"="happy" )); then
     :
else
   command
   command
fi

The Following User Says Thank You to vgersh99 For This Useful Post:
Bill L. (06-26-2013)
    #4  
Old 04-16-2008
april april is offline
Registered User
 
Thanks. That works.
Sponsored Links
👤 Login to reply

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
If statement for null Jack_Maloney Shell Programming and Scripting 6 09-20-2011 12:16 PM
echo statement when find returns null tchoruma UNIX for Dummies Questions & Answers 2 09-24-2009 07:13 AM
write statement into one file rinku Shell Programming and Scripting 5 06-25-2007 05:03 AM
If statement falling over on a null record. Help please. TonyR Shell Programming and Scripting 3 04-29-2006 03:47 PM
How to write an OR statement aukequist Shell Programming and Scripting 1 11-08-2005 04:36 PM



All times are GMT -4. The time now is 01:46 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?