Chinaunix

标题: 判断变量是全数字 [打印本页]

作者: long_ming    时间: 2009-10-12 23:46
标题: 判断变量是全数字

test_num.sh
#!/bin/sh
file_size=128
input_num="$(echo "$1" | sed -n "/^[0-9]\+$/p")"
if [ -n "$input_num" ];then
        echo "Input is the number!"
        file_size="$1"
        echo "file_size = $file_size"
else
        echo "Input isn't the number!"
        echo "Use defaule size $file_size."
fi


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/88438/showart_2068840.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2