剛學習shell的時候,寫了一個娛樂的;想起來寫在這裡,希望大家不要jianxiao!
#!/bin/bash
echo "先選擇運算的種類 加減乘除,然後分别輸入運費的數字就可以得到結果,輸入時間為30秒"
read -p "Please enter the type of operation + or - or * or / :" -t 30 f
case "$f" in
"+")
read -p "Please enter the number1:" -t 30 numb1
read -p "Please enter the number2:" -t 30 numb2
typeset -i numb3="$numb1+$numb2"
echo $numb3
;;
"*")
typeset -i numb3="$numb1*$numb2"
;;
"-")
typeset -i numb3="$numb1-$numb2"
"/")
typeset -i numb3="$numb1/$numb2"
*)
echo "error,Please re-run!"
esac
本文轉自 houzaicunsky 51CTO部落格,原文連結:http://blog.51cto.com/hzcsky/514098