码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2018-12-08 11:25:56      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:col   lse   字符串   chmod   class   echo   sudo   字符串长度   nbsp   

 

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

标签:col   lse   字符串   chmod   class   echo   sudo   字符串长度   nbsp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!