运维网's Archiver
论坛
›
Shell/Powershell
› 判断变量类型的shell脚本
zpjx
发表于 2018-8-21 08:53:39
判断变量类型的shell脚本
脚本一:
#!/bin/bash
echo $a|grep >/dev/null
if [ $? -eq 0 ];then
echo "string"
else
echo "data"
fi
脚本二:
#!/bin/bash
if [[ $a != *[^0-9]* ]]&&[[ $a != 0* ]]
then
echo $a is data
else
echo $a is string
fi
页:
[1]
查看完整版本:
判断变量类型的shell脚本