無法運行此程序。我確信我做錯了什麼,我確定我忽略了一些事情。殼體測試條件出錯
a=3
echo "Type in the first Grade Number."
read num1;
echo "Type in the Second Grade Number."
read num2;
echo "Type in the third Grade Number."
read num3;
echo \($num1 + $num2 + $num3\)/$a | bc
read num;
if [ $num-lt 79 ]
then
echo "The Grade Number is an C."
elif [ $num-lt 89 ]
then
echo "The grade number is an B."
elif [ $num-lt 99 ]
then
echo "Your grade number is an A."
elif [ $num-lt 60 ]
then
echo "You have a failing number"
fi
。注意,沒有人會被報告爲不及格;他們最差的時候會得到一個C等級。那些平均分數爲100分的A +學生會因爲沒有成績而惱怒。還要注意'read num'將要求用戶重新輸入'bc'給出的答案。如果你想從'bc'獲得答案,可以使用:'num = $(echo「($ num1 + $ num2 + $ num3)/ $ a」| bc)'或者等價的。 –