#!/bin/bash echo "請輸入第一個數" read a echo "請輸入第二個輸" read b if [[ ${b} != *[!0]* ]] && [[ ${a} != *[!0123456789]* ]]; then echo "除數為0!!!!!!!!!!!!!!!!!" echo "和為"`echo $(( ${a} + ${b} ))` echo "差為"`echo $(( ${a} - ${b} ))` echo "積為"`echo $(( ${a} * ${b}))` elif [[ ${a} != *[!0123456789]* ]] && [[ ${b} != *[!0123456789]* ]]; then echo "和為"`echo $(( ${a} + ${b} ))` echo "差為"`echo $(( ${a} - ${b} ))` echo "商為"`echo $(( ${a} / ${b} ))` echo "積為"`echo $(( ${a} * ${b}))` echo "余數為"`echo $(( ${a} % ${b}))` else echo "輸入錯誤" fi
http://xxxxxx/Linuxjc/1176186.html TechArticle