errors in if statement
Hello Sirs,
I'm unable to figure out where I'm going wrong in the if statement of my script. Could you please take a look and help me identify the what I'm doing wrong and in fixing the errors. Thanks in advance. Code:
if ( "$1" == "-u" || "$1" == "-U" ) #line 17 Code:
+ '' == -u |
Try to replace the '()' with '[[]]'.
Like so: Code:
if [[ "foo" == "foo" ]]; then echo "bar"; fi Code:
if (( 1 > 0 )); then echo "true"; fi Best regards, HMW |
This works and looks a bit better:
Code:
opt="$1" |
Maybe you could look at the following seeing as you are trying to process options :- http://www.linuxquestions.org/questi...andling-34675/
|
Remove spaces on both the LHS and RHS of the ==.
OK |
Quote:
|
( string ) means you want to execute the string (inside) in a new shell.
As you can see the string is '' == -u (or similar) which cannot be executed. You need to change () to [[]] or use switch/case. |
C.. prog.
Hi new_user....! Welcome!
From the parentheses, I'm guessing you have *programming* experience [?] In csh, a C-language-like shell a few pages down, in here, your code would *almost* work (except csh uses "else if" and "endif", so the "elif/fi" makes it obvious you mean [ba]sh) Anyway... Enjoy... Best Wishes! |
Appreciate your help. Thanks for all your replies!!
|
All times are GMT -5. The time now is 04:45 AM. |