-2
我不知道是哪裏的問題:當我執行,我得到一個錯誤:比較數字雙數在bash
./script.sh: line 4: if[ 7 -gt 5 ]: command not found
./script.sh: line 5: syntax error near unexpected token then'
./script.sh: line 5: `then'
#!/bin/bash
read a
read b
if[ $a -gt $b ]
then
echo "$a is greater than $b"
elif [ $a -lt $b ]
then
echo "$a is less than $b"
else
echo "$a is equal to $b"
fi
正如bash標籤維基建議的那樣,您應該先在http://shellcheck.net/上運行您的代碼,然後再問問題。 –
請注意,間距在外殼中至關重要。你必須非常小心 - 既不太多也不太少。 –