利用shell实现超简单计算器

#!/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,linux)