2013年(6)
分类: AIX
2013-03-15 15:57:04
1. [[ ]] — 比较字符串
2. (( )) — 比较数字
3. test command — 支持Bourne shell 和KornShell4. []— 支持Bourne shell 和 KornShell
例1:
if [[ “$response” = “Yes” ]]
then
print “Okay, we’re going ahead.”
fi
例2:
$ XX=17
$ (( $XX == 17 ))
$ print $?
0
例3:
$ XX=17
$ test $XX -eq 17
$ print $?
0
例4:
$ XX=17
$ [ $XX -eq 17 ]
$ print $?
0
注意:在[ $XX -eq 17 ],(( $XX == 17 )),[[ “$response” = “Yes” ]],
括号的前后都有空格,不然会报错。