ip=$(ip addr|sed -nr 's#^.*inet (.*)/24.*$#\1#gp')
if [ ! $ip ];then
echo "not ok"
else
echo "ok"
fi
Shell判断变量值是否存在
最新推荐文章于 2024-07-16 16:44:12 发布
ip=$(ip addr|sed -nr 's#^.*inet (.*)/24.*$#\1#gp')
if [ ! $ip ];then
echo "not ok"
else
echo "ok"
fi