Reputation: 217
I feel like my brain stopped working. Clearly, this logic is wrong but I can't figure it out. I suspect I just need to negate the whole thing, but not sure...why does the following not work:
#!/bin/bash
a=0
b=20
c=30
d="yes"
e="yes"
echo a,b,c,d,e = $a, $b, $c, $d, $e
if [[ $a -eq 1 || $b -gt $c || $d -eq "no" || $e -eq "no" ]];
then
echo a is 1, or b is greater than c, or d is no, or e is no
else
echo no conditions are true
fi
result:
a,b,c,d,e = 0, 20, 30, yes, yes
a is 1, or b is greater than c, or d is no, or e is no
Upvotes: 0
Views: 48
Reputation: 206699
Don't use -eq
to compare strings - it only compares numbers. Use =
instead.
Upvotes: 4