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

每天进步一点点,快乐生活多一点。
原文地址:https://www.cnblogs.com/yiruliu/p/10756822.html