![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem with if, while, for conditions | kittusri9 | Shell Programming and Scripting | 3 | 04-24-2008 09:15 AM |
| Multiple conditions in find or ls stmts | mavsman | UNIX for Dummies Questions & Answers | 5 | 04-01-2008 04:57 PM |
| if statement with two conditions | cin2000 | Shell Programming and Scripting | 1 | 01-23-2006 03:21 PM |
| if statement with two conditions -e, && | yongho | Shell Programming and Scripting | 16 | 06-14-2005 04:46 PM |
| multiple conditions in if statements | tim mauger | Shell Programming and Scripting | 3 | 04-28-2002 09:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
multiple conditions in if/then
Hello,
I am having trouble with the syntax with a conditional statement in a BASH script involving multiple conditions. Any suggestions would be greatly appreciated! if [ "$sString" != "2" && "$sString" != "5" && "$sString" !="8 " && "$tString" !="3" && "$tString" != "5" ]; then array=("${array[@]}" "$dnNum" ) fi i receive this error: ./testscript: [: missing `]' |
|
||||
|
The last example is failing because of your "5" sitting next to the "]" with no whitespace.
Your first example will work if you replace "&&" with "-a" or if you replace your brackets "[" and "]" with double brackets "[[" and "]]". Example: Code:
if [ "$sString" != "2" -a "$sString" != "5" ]; then ... fi Code:
if [[ "$sString" != "2" && "$sString" != "5" ]]; then ... fi |
|
||||
|
thank you so much...this was the first time i've posted on a forum, and it def proved its usefulness...
Last edited by grandtheftander; 07-21-2006 at 02:20 PM.. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|