syntax for two different conditions in if statement
hello
i am trying to write a command like if [ a == b ] && [ c == d ] it gives me an error [: missing `]' can any one help me with the syntax and also explain what this error means thanks in advance |
that line looks actually ok, so you should tell us explicitly what caused your problem.
|
I have no idea what the problem is. Maybe [: missing `]'means that there is a bracket missing. I checkd and all the brackets are closing. Is there any other way of writing the syntax?
|
Do you have spaces around the brackets? Remember that [ is a synonym for test and you would not write, iftesta==b]
|
this worx for me:
Code:
[schneidz@hyper Documents]$ bash --version |
Well... assuming a b and c are shell variables, you need $a $b and $c to test the VALUE of the variables.
As in: Code:
a=1 Code:
a=1 Note "==" is a string comparison, thus a == b is always false... If a/b/c are supposed to be numeric, then use -eq. |
All times are GMT -5. The time now is 04:00 PM. |