Bashシェルスクリプト/数値チェック の変更点


*数値チェック [#o9f404ae]
[[dokuwiki.fl8.jp>http://dokuwiki.fl8.jp/doku.php/bash/script/07_check_numeric]]
[[dokuwiki.fl8.jp掲載済>http://dokuwiki.fl8.jp/doku.php/bash/script/07_check_numeric]]

文字列からsedを利用して、数字を全部消します。~
そして、残った文字列が0なら数字だけ、0じゃなければ、文字列も含まれる。

 A=`echo -n $1|sed 's/[0-9]//g' `
 if [ -n "$A" ]; then
   echo "文字列も含まれます。"
 else
   echo "数値だけです。"
 fi