What does -z mean in Bash? [duplicate]
Solution 1:
-z string
True if the string is null (an empty string)
Solution 2:
-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.
Solution 3:
test -z
returns true if the parameter is empty (see man sh
or man test
).
Solution 4:
The expression -z string
is true if the length of string is zero
.