标签:
直接上脚本,
使用$(())以及$[]进行数字计算
数值比较:
n1 -eq n2检查n1是否等于n2 n1 -le n2检查n1是否小于等于n2
n1 -ge n2检查n1是否大于等于n2 n1 -lt n2检查n1是否小于n2
n1 -gt n2检查n1是否大于n2 n1 -ne n2检查n1是否不等于n2
#!/bin/bash numa=1; numb=2; numc1=$(($numa - $numb)); numc2=$[$numa + $numb]; echo "numc1 = $numc1, numc2 = $numc2" if [ $numc1 -lt 0 ] then echo "numc1 less then 0" fi if [ $numc2 -gt 0 ] then echo "numc2 great then 0" fi numd1=$(($numc1 + 9)); numd2=$[$numc2 - 9]; echo "numd1 = $numd1, numd2 = $numd2" if [ $numd1 -gt $numd2 ] then echo "numd1 great then numd2" else echo "numd1 not great then numd2" fi
参考:
http://www.cnblogs.com/linuxer/archive/2012/06/20/2870518.html
标签:
原文地址:http://www.cnblogs.com/xiaoxian1369/p/4638412.html