判断变量类型的二个shell/ target=_blank class=infotextkey>shell脚本。
例1,脚本一:
#!/bin/bash
#
echo $a|grep [a-zA-Z]>/dev/null
if [ $? -eq 0 ];then
echo "string"
else
echo "data"
fi
例2,脚本二:
#!/bin/bash
#
if [[ $a != *[^0-9]* ]]&&[[ $a != 0* ]]
then
echo $a is data
else
echo $a is string
fi