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

时间:2018-12-08 10:53:55   收藏:0   阅读:553

 

test.sh

#!/bin/bash
echo "enter the string:"
read filename
if test -z $filename ; then
echo "the length is 0"
else
echo "the length is not 0"
fi

执行

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

输出

enter the string:

the length is 0

 

执行

./test.sh

输出

enter the string:
sssssss
the length is not 0

 

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!