001、 expr
[root@localhost test]# expr 3 + 5 8 [root@localhost test]# expr 3 - 5 -2 [root@localhost test]# expr 3 * 5 15 [root@localhost test]# expr 3 / 5 ## 支持加减乘除 0 [root@localhost test]# expr 3 / 5.3 ## 不支持浮点运算 expr: non-integer argument [root@localhost test]# expr 5 / 3 1 [root@localhost test]# expr 8 / 3 ## 直接截断 2
002、echo + bc
[root@localhost test]# echo "5 + 3" | bc 8 [root@localhost test]# echo "5 - 3" | bc 2 [root@localhost test]# echo "5 * 3" | bc 15 [root@localhost test]# echo "5 / 3" | bc 1 [root@localhost test]# echo "scale = 3; 5 / 3" | bc ## 支持浮点运算 1.666 [root@localhost test]# echo "scale = 5; 5 / 3" | bc 1.66666
。