Use of -z in while loop condition

Hi,

Could you please tell what is the meaning of -z in while loop condition.
For example,

while [ -z "$name" ]; do
echo "*** Enter the age "
readage

-z means NULL

while [ -z "$name" ]; do means while value of $name is null.

1 Like

Things inside brackets are a "test". -z tests "$name" to see if its length is zero.

from "man test":
-z String1
Returns a True exit value if the length of the String1 variable is
0 (zero).

1 Like

usage : -z <string_name>

meaning: <string_name> is NULL and does exist

it is used in if,while ,....