我要求用戶輸入2個數字和s作爲總和,或者「p」表示產品。 當我運行該腳本,我沒有看到任何結果 這裏是我的腳本根據輸入計算總和或產品
#!/bin/bash
read -p "please enter two integers, s or p to calculate sum or product of this numbers: " num1 num2 result
if [ result == "s" ]
then
echo "num1+num2" | bc
elif [ result == "p" ]
then
echo $((num1*num2))
fi
真棒,謝謝! – Ana