返回列表 回复 发帖

我用shell的正则表达式来判断为数字时,这样写怎么不对呀!求救!

#!/bin/csh

set a = dsd2

if (${a} =~ [0-9]+) then
echo "全为数字"
endif
#!/bin/bash

a=$1

if [ ! -z $(echo $a | sed 's/[0-9]//g') ] ; then
   echo "invalid"
fi
返回列表