problem using logical or


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers problem using logical or
# 1  
Old 06-08-2009
problem using logical or

Hi,

I have a script testor.s which takes a string as command line argument,
Contents of the script:

#!/bin/ksh -x
if [[ "WO_STMT_05292009" != "$1" || "WO_BENE_STMT_05292009" != "$1" ]]
then
echo "error"
else
echo "correct"
fi

Here, though i provide the command line argument as "WO_STMT_05292009", it displays error

Is there any problem with the way i have implemented logical or?

Thanks,
Sheema
# 2  
Old 06-08-2009
this will work...

Code:
if [[ "$1" = "WO_STMT_05292009" || "$1" = "WO_BENE_STMT_05292009" ]]
then
echo "correct"
else
echo "error"
fi

# 3  
Old 06-08-2009
Quote:
Originally Posted by Sheema
Hi,

I have a script testor.s which takes a string as command line argument,
Contents of the script:

#!/bin/ksh -x
if [[ "WO_STMT_05292009" != "$1" || "WO_BENE_STMT_05292009" != "$1" ]]
then
echo "error"
else
echo "correct"
fi

Here, though i provide the command line argument as "WO_STMT_05292009", it displays error

Is there any problem with the way i have implemented logical or?

Thanks,
Sheema
The || should be && in the test conditions:

Code:
if [[ "WO_STMT_05292009" != "$1" && "WO_BENE_STMT_05292009" != "$1" ]]

# 4  
Old 06-08-2009
Thanks Shubhendu and Franklin52....both the code works for me.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Logical Partitions?

I'm trying to find out how many logical partitions our AIX box has. I'm running the command: topas -C and nothing is showing up. Is it safe to say that there is only one LPAR, which is what AIX is installed on? Move to AIX - jim mc (2 Replies)
Discussion started by: NycUnxer
2 Replies

2. Shell Programming and Scripting

Logical error

I have this script to uvscan-update. Seems like that i am getting logical error at the end of the script. It is updating the script and also giving the error message to update it manually. I have deleted the DAT files to see if it will create new and it does. Below is the error and the script: ... (1 Reply)
Discussion started by: mk07md
1 Replies

3. Shell Programming and Scripting

A logical problem.

I'm having a logical problem.Can anybody help me. while ] do echo " Enter the Zip File Name : \c" read ZipFile done In the above snippet - I want it ask for file name first time and once validation fails, I want it add a msg that its entered file name doesn't exist and ten prompt... (3 Replies)
Discussion started by: dashok.83
3 Replies

4. Shell Programming and Scripting

op of logical operator

Why the op of the following code is like this ???? i=4 j=-1 k=0 echo $? echo $? echo $? (5 Replies)
Discussion started by: lipun4u
5 Replies

5. Shell Programming and Scripting

How to do logical AND and logical OR with grep

Hi can someone please help me on this. I need to perform this code: Grep any lines that meets the following criteria (A AND B) OR (A AND C) I tried this code, but it didn't work Grep-I "A &&B" | "A&&C" *.* $ thanks in advance (12 Replies)
Discussion started by: Needhelp2
12 Replies

6. UNIX for Advanced & Expert Users

Problem syncing logical volume in root vg

Hello. I have a test server that I'm messing around with, and just recently received an error on startup that a logical volume in the root volume group couldn't be re-synchronized. Server boots fine, as the root vg is mirrored, but I'd like to get rid of the error. Here are the details: ... (1 Reply)
Discussion started by: matt.d
1 Replies

7. Shell Programming and Scripting

logical OR in sed

frnds.. can i perform an OR operation in sed syntax ? if yes.. how? I need to search for some 2-3 mail addresses in multiple files and delete all those... and instead of them.. I need to insert a new mail id...( these are also other emails in that list .. which sud not be affected ) is... (8 Replies)
Discussion started by: clx
8 Replies

8. News, Links, Events and Announcements

Did not know about logical volumes

I had just updated - reinstalled - my RH9 to a Fedore Core 3. I did not know about the Logical volumes that automatically combined partitions on drive 1 and 2 into one mounted volume. In my attempts to do something with the hdb2 partition - not knowing that it was already in use - I killed my... (2 Replies)
Discussion started by: gezi
2 Replies
Login or Register to Ask a Question