如何在Bash中查找变量是否为空? [英] How to find whether or not a variable is empty in Bash?
本文介绍了如何在Bash中查找变量是否为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查Bash中的变量是否为空?
How can I check if a variable is empty in Bash?
推荐答案
在Bash中,至少以下命令测试 $ var是否为空:
In Bash at least the following command tests if $var is empty:
if [[ -z "$var" ]]; then
# Do what you want
fi
命令 man test
是您的朋友.
这篇关于如何在Bash中查找变量是否为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文