shell脚本实现算术运算且输入的不能为非数字的值

#!/bin/bash

c=

while [ ${c} -eq   ]
do
echo "请输入第一个数"
read a
echo "请输入第二个数"
read b if [[ ${b} != *[!]* ]] && [[ ${a} != *[!]* ]] && [ -n "${a}" ] && [ -n "${b}" ] ; then
sleep
echo " "
echo " "
echo "和为:"`echo $(( ${a} + ${b} ))`
echo "差为:"`echo $(( ${a} - ${b} ))`
echo "积为:"`echo $(( ${a} * ${b}))`
echo " "
sleep
echo -e "\033[33m除数为0,无法进行除法运算以及取余运算!\033[0m" c=$(( ${c} + ))
elif [[ ${a} != *[!]* ]] && [[ ${b} != *[!]* ]] && [ -n "${a}" ] && [ -n "${b}" ] ; then
sleep
echo " "
echo " "
echo "和为:"`echo $(( ${a} + ${b} ))`
echo "差为:"`echo $(( ${a} - ${b} ))`
echo "商为:"`echo $(( ${a} / ${b} ))`
echo "积为:"`echo $(( ${a} * ${b}))`
echo "余数为:"`echo $(( ${a} % ${b}))` c=$(( ${c} + )) else sleep echo " " echo -e "\033[31m输入错误,请从新输入正确的值!\033[0m" echo " "
fi done
上一篇:【Android 应用开发】Android屏幕适配解析 - 详解像素,设备独立像素,归一化密度,精确密度及各种资源对应的尺寸密度分辨率适配问题


下一篇:solr update接口常用方法