Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is -z in if [ -z "${FILE_LIST}" ]

Tags:

shell

Came across this, what is -z in the shell script if [ -z "${FILE_LIST}" ]?

like image 731
Oh Chin Boon Avatar asked Dec 12 '22 09:12

Oh Chin Boon


2 Answers

[ is the same as test. And man test gives:

   -z STRING
          the length of STRING is zero

Note: On some platforms, [ is a symlink or hardlink to test

like image 103
Stéphane Gimenez Avatar answered Feb 21 '23 08:02

Stéphane Gimenez


From help test:

  -z STRING      True if string is empty.
like image 29
Ignacio Vazquez-Abrams Avatar answered Feb 21 '23 09:02

Ignacio Vazquez-Abrams