...
#!/bin/bash c=1 while [ ${c} -eq 1 ] do echo "請輸入第一個數" read a echo "請輸入第二個數" read b if [[ ${b} != *[!0]* ]] && [[ ${a} != *[!0123456789]* ]] && [ -n "${a}" ] && [ -n "${b}" ] ; then sleep 1 echo " " echo " " echo "和為:"`echo $(( ${a} + ${b} ))` echo "差為:"`echo $(( ${a} - ${b} ))` echo "積為:"`echo $(( ${a} * ${b}))` echo " " sleep 2 echo -e "\033[33m除數為0,無法進行除法運算以及取餘運算!\033[0m" c=$(( ${c} + 1 )) elif [[ ${a} != *[!0123456789]* ]] && [[ ${b} != *[!0123456789]* ]] && [ -n "${a}" ] && [ -n "${b}" ] ; then sleep 1 echo " " echo " " echo "和為:"`echo $(( ${a} + ${b} ))` echo "差為:"`echo $(( ${a} - ${b} ))` echo "商為:"`echo $(( ${a} / ${b} ))` echo "積為:"`echo $(( ${a} * ${b}))` echo "餘數為:"`echo $(( ${a} % ${b}))` c=$(( ${c} + 1 )) else sleep 3 echo " " echo -e "\033[31m輸入錯誤,請從新輸入正確的值!\033[0m" echo " " fi done