Home Man
Search
Today's Posts
Register

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

Tags
if statement, null, shell scripts, write

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 04-16-2008
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.
# 2  
Old 04-16-2008
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.
# 3  
Old 04-16-2008
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:
# 4  
Old 04-16-2008
Thanks. That works.
Login to Reply

« Previous Thread | Next 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
Convert Update statement into Insert statement in UNIX using awk, sed.... dev123 Shell Programming and Scripting 0 03-22-2016 03:37 AM
Awk/sed problem to write Db insertion statement bhaskar_m Shell Programming and Scripting 6 08-27-2013 06:23 AM
Need a clue to write a IF statement Soma Das Shell Programming and Scripting 6 07-25-2012 07:31 AM
If statement for null Jack_Maloney Shell Programming and Scripting 6 09-20-2011 12:16 PM
How to write If statement using && and operator in Unix Avi Shell Programming and Scripting 2 06-01-2011 07:35 AM
echo statement when find returns null tchoruma UNIX for Dummies Questions & Answers 2 09-24-2009 07:13 AM
How is use sselect statement o/p in insert statement. nkosaraju Shell Programming and Scripting 2 08-06-2008 09:26 PM
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 07:05 PM.

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