我有这些变量:
a=`echo "$(xmllint --xpath '/rates/currency['code="\"$codea\""']/amount/text()' rates.xml)"`
b=`echo "$(xmllint --xpath '/rates/currency['code="\"$codeb\""']/amount/text()' rates.xml)"`
让我们说a = 10000 B = 1
如果我想验证变量a是否大于变量b,我如何写if语句?
答案 0 :(得分:2)
经典方式:
if [ $a -gt $b ]
then
something here ...
else
something different ...
fi
变种:
if [[ $a -gt $b ]]
或者可以使用算术扩展
if (( a > b )); then whatever; else anything; fi