首页 > 系统服务 > 详细

shell 判断字符串长度是否不为0

时间:2018-12-08 10:20:13      阅读:555      评论:0      收藏:0      [点我收藏+]

 

test.sh

#!/bin/bash
s1=""
if test $s1 ;then
echo "length is not zero"
else
echo "the length is 0"
fi
s2="shell"
if test $s2 ;then
echo "length is not 0"
else
echo "the length is 0"
fi

执行

sudo chmod +x test.sh
./test.sh

输出

the length is 0
length is not 0

 

shell 判断字符串长度是否不为0

原文:https://www.cnblogs.com/sea-stream/p/10085960.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!