issue with multiple logical operators


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers issue with multiple logical operators
# 1  
Old 09-01-2010
issue with multiple logical operators

Hi,
shell is /bin/ksh

I am trying to do the following in my code.. but its showing me an error


Code:
if [[ [[ "$ida" == "_W_" || "$ida" == "_SA" ]] && [[ "$chk_dy" == "Sun" || "$chk_dy" == "Sat" ]] ]]; then

                        echo "id is $ida and chk_dy is $chk_dy"
fi

the error I get is
syntax error at line 23 : `"$ida"' unexpected

I need to execute the condition together.


I need to check
if (( ida is W or SA ) and (chk_dy is Sat or Sud ))

Many Thanks
# 2  
Old 09-01-2010
remove the outer brackets.

Code:
if [[ "$ida" == "_W_" || "$ida" == "_SA" ]] && [[ "$chk_dy" == "Sun" || "$chk_dy" == "Sat" ]]; then
   echo "id is $ida and chk_dy is $chk_dy"
fi

This User Gave Thanks to frank_rizzo For This Post:
# 3  
Old 09-01-2010
That works !!
El perfecto !!!!!!!!!!!!!!!!!!

I spent almost half hr trying to fix this !!!!!!!!!!!!!

muchas gracias FrankSmilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Issue with search and replacing multiple items in multiple files

Im having an issue when trying to replace the first column with a new set of values in multiple files. The results from the following code only replaces the files with the last set of values in val.txt. I want to replace all the files with all the values. for date in {1..31} do for val in... (1 Reply)
Discussion started by: ncwxpanther
1 Replies

2. Shell Programming and Scripting

Implementing operators on multiple fields

Hallo Friends, Have a look at my script: awk -F',' '$14==9100' *_201304*.csv|wc -l > pax1; awk -F',' '$14==9101' *_201304*.csv|wc -l >>pax1; awk -F',' '$14==9102' *_201304*.csv|wc -l >>pax1; awk -F',' '$14==9103' *_201304*.csv|wc -l >>pax1 I would like to include field 42. like below ... (9 Replies)
Discussion started by: kekanap
9 Replies

3. Shell Programming and Scripting

How to use logical operators in multiple if statement

Hi I want to send a status mail if daily or weekly or monthly batch completed or aborted. Here is the code. if && && || Else if && && || Else if && && || then mailx –s “Status Report” sumone@sumthing.com else print ”try again” Plz suggest the changes. (3 Replies)
Discussion started by: Avi
3 Replies

4. Shell Programming and Scripting

ksh Multiple Pattern Matching Operators

I figured this would be simple, but I am stuck. Variable longpath="/dir1/dir2/dir3/filename.stuff.morestuff.garbage" I want to end up with just "filename.extra.moreextra". So, I want to get rid of the path and .garbage I want to do this with just ksh internals. So, no sed,grep,awk,expr,... (4 Replies)
Discussion started by: Topaz
4 Replies

5. Shell Programming and Scripting

Precedence in operators issue

Hello, I am trying to write a small acript to change directory to $HOME depending on the user logged in. However when i provide this command say, ABC_USER=myself cd ~${ABC_USER} i am getting the following error, ksh: ~myself: not found I know i am doing something really silly but... (4 Replies)
Discussion started by: arvindspr06
4 Replies

6. Shell Programming and Scripting

Can you use logical operators in a case statement (bash)?

I'm pretty sure I already know the answer to this, but I want to make sure I'm not overlooking anything. I'm working on a log monitoring script and every 10 lines I want to display a summary of events. The thing is, there are a lot of possible events, that likely won't have happened, so I only want... (0 Replies)
Discussion started by: DeCoTwc
0 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Multiple Process issue

Hello all, First of all, I want to thank the forum for being so helpful to me in many occasions. I have searched through the forums and the internet. I couldnt find a perfect solution for my issue. Here is what Im trying to do.. Im verifying a bunch of jobs whether they are completed or not... (1 Reply)
Discussion started by: jntgopal
1 Replies

9. Shell Programming and Scripting

Multiple Logical Operator Issues ...

Hi folks I have a snippet of code Which is like this If ( ( A || B || C ) && D ) then Do some thing.... elif exit fi How to rephrase this and use it so I dont get any Errors ... Looking out for helpful replies .. Thanks & Regards Srikanth GR (1 Reply)
Discussion started by: srikanthgr1
1 Replies

10. UNIX for Dummies Questions & Answers

multiple Logical statement

hi I have following if condition line_by_line="0000000000000tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt" if then echo "Exclusion criteria" else echo "Not exclusion criteria" fi above condition works perfectley but if i add one more logical condition... (3 Replies)
Discussion started by: mahabunta
3 Replies
Login or Register to Ask a Question