Linux之判断字符串是否为空

help命令可以查看帮助

help test

 

正确做法:

 

#!/bin/sh

STRING=

if [ -z "$STRING" ]; then 
    echo "STRING is empty" 
fi

if [ -n "$STRING" ]; then 
    echo "STRING is not empty" 
fi

posted @ 2019-04-23 15:45  意如柳  阅读(5106)  评论(0编辑  收藏  举报