ksh if with several conditions
10,192
Whatever $tmpEngine
value, this test is always true, I mean, $tmpEngine
cannot be a
, b
and s
at the same time so at least two of the comparisons are always true.
You probably want:
if [[ "$tmpEngine" != "a" && "$tmpEngine" != "b" && "$tmpEngine" != "s" ]]; then
...
fi
Related videos on Youtube
![user1058398](https://i.stack.imgur.com/0bdQq.jpg?s=256&g=1)
Author by
user1058398
Updated on September 18, 2022Comments
-
user1058398 almost 2 years
I'd like to know what's the syntax for this kind of if in ksh :
if [[ $tmpEngine != "a" || $tmpEngine != "b" || $tmpEngine != "s" ]]; then ... fi
Actually, my code doesn't work, what's the problem here ? The problem is not about the meaning of my if, but rather how to write it correctly from a syntax point of view.
-
user1058398 over 10 yearsYou right, small mistake from my side but anyway, my code doesn't work because of a syntax problem.
-
jlliagre over 10 yearsDo you mean my answer doesn't address the problem described ?