If statement - How to write a null statement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If statement - How to write a null statement
# 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

This User Gave Thanks to vgersh99 For This Post:
# 4  
Old 04-16-2008
Thanks. That works.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. Shell Programming and Scripting

Awk/sed problem to write Db insertion statement

Hi There, I am trying to load data from a csv file into a DB during our DB migration phase. I am successfully able export all data into a .csv file but those have to rewritten in terms insert statement which will allow for further population of same data in different DB My exiting csv record... (6 Replies)
Discussion started by: bhaskar_m
6 Replies

3. Shell Programming and Scripting

Need a clue to write a IF statement

Hi all, i am writing a shell script in which i got stuck when tried to use a if statement. This is my code : #!/bin/sh today=`date +"%a %b %e"` find /prod/logs -name '*.log' -mtime 0 -exec cp {} /home/hzjnr0/test \; find /home/hzjnr0/test -type f -exec grep -i "successfully" {} \; >... (6 Replies)
Discussion started by: Soma Das
6 Replies

4. Shell Programming and Scripting

If statement for null

Hi, I want to be able to check if a variable is not equal to null. I am using KSH, and am getting this error message when i run this script: : assignment requires lvalue The line which is causing the problem is as follows: if (($SFTP_DESTINATION != '' ));then if ssh... (6 Replies)
Discussion started by: Jack_Maloney
6 Replies

5. Shell Programming and Scripting

How to write If statement using && and operator in Unix

Hi What is the syntax for if statement using && and || operator? if && ] || here its giving me an error to this if statement any suggestion?? (2 Replies)
Discussion started by: Avi
2 Replies

6. UNIX for Dummies Questions & Answers

echo statement when find returns null

Hi, How do you echo something once when a find statement returns null results? This is when using mutiple locations and mutiple arguments. The below find command the inner loop of a nested for loop where the outter loop holds the $args and the inner loop holds the locations. find... (2 Replies)
Discussion started by: tchoruma
2 Replies

7. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

8. Shell Programming and Scripting

write statement into one file

I have one file name start.sh in rinku directory. I want to move it to rinku1 directory. I also mantain log file. In the log file I want to write the the statement whenever the move is failed. Example: >echo `mv /rinku/me.tx ../rinku1` | tee -a log1 mv: me.tx: cannot access: No such file or... (5 Replies)
Discussion started by: rinku
5 Replies

9. Shell Programming and Scripting

If statement falling over on a null record. Help please.

Okay i've got some code which reads a text file and loops through it and there a few if statements inside where one is failing (the one bolded). Basically the acc column contains a list of three digit access codes, some though have null records (i.e nothing in the field) so what I want to do is... (3 Replies)
Discussion started by: TonyR
3 Replies

10. Shell Programming and Scripting

How to write an OR statement

Hi all, I want to check if the first or the second or the third argument of call to a shell script is empty. How do i do that in a short way. I watched some examples and i believe if checks if an argument is NULL. If so, how can i add the checks for argument 2 and 3 in the statement? ... (1 Reply)
Discussion started by: aukequist
1 Replies
Login or Register to Ask a Question