a=10
b=20
c=30
if [[ $a -gt $b && $a -gt $c ]]
then
echo "A is the greater number"
if [[ $b -gt $a && $b -gt $c ]]
then
echo "B is the greater number"
else
echo "C is the greate number"
fi
我尝试进行 dos2unix 格式化,添加另一个“fi”,但代码仍然抛出相同的错误
您有两个
if
语句,但只有一个 fi
。尝试使用 elif
来代替第二种情况:
a=10
b=20
c=30
if [[ $a -gt $b && $a -gt $c ]]; then
echo "A is the greater number"
elif [[ $b -gt $a && $b -gt $c ]]; then
echo "B is the greater number"
else
echo "C is the greater number"
fi