-z是什么意思在Bash?
我正在看下面的代码:
if [ -z $2 ]; then echo "usage: ...
(这3个点是不相关的使用细节。)
也许我错了,但我找不到-z选项的解释。
-z string如果string为空,则为真(空string)
-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.
如果参数为空,则test -z返回true(请参阅man sh或man test )
如果string的长度zero ,则expression式-z string为true。