#!/bin/bash
read -p "请输入第一个数:" num1
read -p "请输入运算符:" fuhao
read -p "请输入第二个数" num2
if [ "$fuhao" == "+" ]
then
echo $num1+$num1=$(($num1 + $num2))
elif [ "$fuhao" == "-" ]
then
echo $num1-$num2=$(($num1 - $num2))
elif [ "$fuhao" == "*" ]
then
echo $num1*$num2=$(($num1 * $num2))
elif [ "$fuhao" == "/" ]
then
echo $num1/$num2=$(($num1 / $num2))
else
echo "错误"
fi
利用shell实现超简单计算器
最新推荐文章于 2024-08-01 19:18:39 发布