下邊的簡易計算器為何執(zhí)行不了?
#!/bin/bash read?-t?30?-p?"please?inputA" read?-t?30?-p?"please?inputB" read?-t?30?-p?"please?choose?+/-/*//:"?C case?$C?in ?????????"+") ?????????echo$(($A+$B)) ?????????;; esac
#!/bin/bash read?-t?30?-p?"please?inputA" read?-t?30?-p?"please?inputB" read?-t?30?-p?"please?choose?+/-/*//:"?C case?$C?in ?????????"+") ?????????echo$(($A+$B)) ?????????;; esac
2016-06-21
舉報
2016-06-22
沒有將鍵盤輸入的值賦給變量A和B,改成下面的就行了
#!/bin/bash?
read?-t?30?-p?"please?inputA" A
read?-t?30?-p?"please?inputB" B
read?-t?30?-p?"please?choose?+/-/*//:"?C
case?$C?in
?????????"+")
?????????echo$(($A+$B))
?????????;;
esac
2016-06-22
#!/bin/bash
#echo "1.$12.$23.$3"
if [ "$2" == "+" ]
then
?? ?RES=`expr $1 + $3`
?? ?echo ">>the result is:$RES"
elif [ "$2" == "-" ]
then
?? ?RES=`expr $1 - $3`
?? ?echo ">>the result is:$RES"