![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with For Statements | lexydoll87 | UNIX for Dummies Questions & Answers | 22 | 05-01-2009 01:58 AM |
| HELP!! if statements | trob | Shell Programming and Scripting | 1 | 04-01-2009 03:24 PM |
| Please help on IF statements. | filthymonk | Shell Programming and Scripting | 4 | 07-18-2007 06:59 AM |
| Else in If Statements | chapmana | UNIX for Dummies Questions & Answers | 8 | 11-30-2006 08:07 AM |
| or statements? | Blip | Shell Programming and Scripting | 1 | 01-19-2004 04:08 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
[SOLVED]IF-Statements not working
Dear Community, I tried for over 4 days to figur this out. I got a Shell-Code which contains some If-statements which are driving me crazy. First of all the statements: Code:
err=0; echo "If-Test begins..." if ! [[ "$err"==1 ]];then echo "If NOT 0" fi if [[ "$err"!=0 ]];then echo "If NOT (inside braces) 0" fi if [[ "$err"==1 ]];then echo "If 0" fi if [[ "$err"==1 ]];then echo "Using \" for 0" fi As "err" is 0 the last two statements shouldn't become true. But when I am running the scrip the secon, third and fourth statement are returning "true" back, the first one not. I really cannot get it... Where is my mistake? Actually I tried every form of the comparison: Code:
$err=0 $err==0 "$err"="0" "$err"=="0" '$err'='0' '$err'=='0' $'err'='0' $'err'=='0' I also tried to mix the various format (eg. $err=="0") but really nothing is working. ---------- Post updated at 05:29 AM ---------- Previous update was at 05:22 AM ---------- Nervermind, just realisied that I have to put whitespaces between the argument and the variable... Thanks anyway! Last edited by Henry_Ford; 09-16-2009 at 07:30 AM.. Reason: [SOLVED] |
| Bookmarks |
| Tags |
| bash, if-statements, script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|