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

2019-07-19 04:31发布

问题:

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

回答1:

[ 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



回答2:

From help test:

  -z STRING      True if string is empty.


回答3:

-z tests for a zero-length string.



回答4:

I think if you're using bash, then it would return true if the length of the string is zero (so in your case, there are no files in the list).



标签: shell