【发布时间】:2025-12-03 01:05:01
【问题描述】:
我正在编写一个简单的 ksh 脚本。我必须检查一个字符串是否为空。怎么做?这就是我所拥有的:
findRes=`find . -name believe | xargs grep -q "ser"`
if [ "${findRes:-unset}" != "unset" ];then
print "${file}"
fi
【问题讨论】:
-
我觉得添加
else应该就足够了,因为您将$findRes默认值设置为“未设置”——因此不能为空......所以像if [ "${findRes:-unset}" != "unset" ];then print "${}" ; else print "Do something when findRes is blank" ; fi
标签: ksh