shell中判断变量是不是是数字

shell中判断变量是否是数字1、http://www.kuqin.com/article/24shell/172512.htmlvar$(echo $1|bc 2/dev/

shell中判断变量是否是数字
1、http://www.kuqin.com/article/24shell/172512.html

var=$(echo $1|bc 2>/dev/null)
if [[ $var != $1 ]]
        then
        echo "$1 isn't a number!"
        exit 1
fi
if echo $1|grep "\." >/dev/null 2>&1
        then
        echo "$1 is float a number!"
        else
        echo "$1 is integer a number!"
fi