我觉得我的大脑停止了工作。显然,这种逻辑是错误的,但我无法弄清楚。我怀疑我只需要否定整个事情,但不确定......为什么以下不起作用:
#!/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
结果:
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
答案 0 :(得分:4)
不要使用-eq
来比较字符串 - 它只比较数字。请改用=
。