一、算术运算符 expr 表达式 or var=`expr 表达式` 1、示例 [root@vm-paas scwyfy]# cat expr_demo.sh #!/bin/bash read -p "请输入第一个数字:" a read -p "请输入第二个数字:" b echo "a=${a}, b= ${b}" echo "a+b= `expr ${a} + ${b}`" echo "a-b= `expr ${a} - ${b}`" echo "a*b= `expr ${a} \* ${b}`" echo "b/a= `expr ${b} / ${a}`" echo "b%a= `expr ${b} % ${a}`" [root@vm-paas scwyfy]# sh expr_demo.sh 请输入第一个数字:1 请输入第二个数字:2 a=1, b= 2 a+b= 3 a-b= -1 a*b= 2 b/a= 2 b%a= 0
标签:shell,数字,expr,echo,运算符,sh,输入 From: https://www.cnblogs.com/yuefeng123/p/18139356