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

2019-07-19 04:29发布

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

标签: shell
4条回答
乱世女痞
2楼-- · 2019-07-19 04:48

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).

查看更多
迷人小祖宗
3楼-- · 2019-07-19 04:51

[ 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

查看更多
趁早两清
4楼-- · 2019-07-19 04:51

-z tests for a zero-length string.

查看更多
何必那么认真
5楼-- · 2019-07-19 05:05

From help test:

  -z STRING      True if string is empty.
查看更多
登录 后发表回答