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

shell 判断一个字符串是否为空

时间:2018-12-08 00:21:24      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:ring   class   str   chm   else   shel   not   code   bsp   

 

test.sh

#!/bin/bash
echo "enter the string:"
read filename
if test $filename ; then
echo "it‘s not zero"
else
echo "it‘s zero"
fi

执行

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

输出

enter the string:

its zero

 

执行

./test.sh

输出

enter the string:
kk
its not zero

 

shell 判断一个字符串是否为空

标签:ring   class   str   chm   else   shel   not   code   bsp   

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

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