我正在看下面的代码:
if [ -z $2 ]; then echo "usage: ...
(3个点是不相关的使用细节) 也许我在谷歌上搜索错了,但我找不到-z选项的解释
-z
如果字符串长度为zero,表达式-z string为真。
zero
-z string
如果参数为空,test -z返回true(参见man sh或man test)。
test -z
man sh
man test
-z string is null, that is, has zero length String='' # Zero-length ("null") string variable. if [ -z "$String" ] then echo "\$String is null." else echo "\$String is NOT null." fi # $String is null.
-z string:如果字符串为空(空字符串)则为True
看到https://www.gnu.org/software/bash/manual/bash.html#Bash-Conditional-Expressions