我正在看下面的代码:
if [ -z $2 ]; then
echo "usage: ...
(3个点是不相关的使用细节。) 也许我搜索错了,但我找不到-z选项的解释。
我正在看下面的代码:
if [ -z $2 ]; then
echo "usage: ...
(3个点是不相关的使用细节。) 也许我搜索错了,但我找不到-z选项的解释。
-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:如果字符串为null(空字符串)则为True
看到https://www.gnu.org/software/bash/manual/bash.html Bash-Conditional-Expressions