shell 判断字符串是否为空

 

#!/bin/bash

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

输出结果为:

-n  : 字符串长度为 0

posted @ 2018-10-31 15:30  anobscureretreat  阅读(599)  评论(0编辑  收藏  举报