shell 判断字符串是否为空

#!/bin/bash

a=""
if [ -n "$a" ]
then
   echo "-n $a : 字符串长度不为 0"
else
   echo "-n $a : 字符串长度为 0"
fi

输出结果为:

-n  : 字符串长度为 0

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