2013-11-28 25 views
0

XML我有這些變量:的if-else-然後在外殼

a=`echo "$(xmllint --xpath '/rates/currency['code="\"$codea\""']/amount/text()' rates.xml)"` 
b=`echo "$(xmllint --xpath '/rates/currency['code="\"$codeb\""']/amount/text()' rates.xml)"` 

比方說,一個= 10000 B = 1

我怎樣寫if語句,如果我想驗證是否變量a比變量b大?

+1

檢查沒用使用回聲。 – ceving

回答

2

的經典方法:

if [ $a -gt $b ] 
then 
    something here ... 
else 
    something different ... 
fi 

的變化:

if [[ $a -gt $b ]] 

還是aritmetic擴大可用於

if ((a > b)); then whatever; else anything; fi