-2
我剛學習shell腳本!我嘗試下面的代碼,但我有錯誤unix所有if語句在一個地方
線15:附近意外的標記`elif的語法錯誤
#!/bin/bash
read -p "Enter the number : " n
if [ $n -eq 1 ]
then
echo "$n is equal to 1 true"
elif [ $n -lt 4 ]
then
echo "$n is less than value of 4 ture"
else
echo "$n is not less then value of 4 false"
elif [ $n -gt 10 ]
then
echo "$n is greater than the value of 10 true"
else
echo "$n is not greater than the value of 10 false"
if [ $n -ge 0 ]
then
echo "$n is greater than or equal to 0"
else
echo "$n is not greater than or equal to 0"
fi
else
"Bye"
fi
誰能幫助?
'if' /'else'或'if' /'elif' /' else'或'if /' elif' /'elif' ... /'else '但不是'if'/'elif' /'else' /'elif' /'else'。 –
在http://www.shellcheck.net/中粘貼代碼顯示您缺少一些'fi's。 – fedorqui
Hay fedorqui感謝您的shellcheck鏈接 – viswa