20101014

Bash: checking if a variable is a number

[code]
# v=1
# [ $v -eq $v ]
# echo $?
0
# v=a
# [ $v -eq $v ]
# echo $?
2
[/code]

Note: "-eq" compares number, but not string.

没有评论:

发表评论