算术表达式嵌套
DEMO:
[xiluhua@vm-xiluhua][~]$ num1=5 [xiluhua@vm-xiluhua][~]$ num2=10 [xiluhua@vm-xiluhua][~]$ num3=$(($num1+$num2)) #嵌套变量加法运算并赋值 [xiluhua@vm-xiluhua][~]$ echo $num3 15 [xiluhua@vm-xiluhua][~]$ num4=$(($num2%3)) #嵌套变量取余运算并赋值 [xiluhua@vm-xiluhua][~]$ echo $num4 1 [xiluhua@vm-xiluhua][~]$ echo $(( 5 > 10 )) #比较运算,假返回0 0 [xiluhua@vm-xiluhua][~]$ echo $(( $num2 > $num1 )) #比较运算,真返回1 1 [xiluhua@vm-xiluhua][~]$ num5=$(( $(($num1>$num2))?$num1:$num2 )) #三目运算符举例 [xiluhua@vm-xiluhua][~]$ echo $num5 10