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
What does this statement mean? Legend986 High Level Programming 1 11-16-2007 11:48 PM
write statement into one file rinku Shell Programming and Scripting 5 06-25-2007 02:03 AM
If Statement lesstjm Shell Programming and Scripting 5 11-05-2006 01:44 PM
If statement falling over on a null record. Help please. TonyR Shell Programming and Scripting 3 04-29-2006 12:47 PM
How to write an OR statement aukequist Shell Programming and Scripting 1 11-08-2005 02:36 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-16-2008
Registered User
 

Join Date: Apr 2007
Posts: 7
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.
Reply With Quote
Forum Sponsor
  #2  
Old 04-16-2008
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,212
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.
Reply With Quote
  #3  
Old 04-16-2008
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,022
Code:
if (( "$x"="1" && "$y"="a" && "$z"="happy" )); then
     :
else
   command
   command
fi
Reply With Quote
  #4  
Old 04-16-2008
Registered User
 

Join Date: Apr 2007
Posts: 7
Thanks. That works.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:56 AM.


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

Content Relevant URLs by vBSEO 3.2.0