-z option inside if condition in shell script

荒凉一梦 提交于 2021-01-16 12:39:37

问题


Can someone post me the significance of -z option while writing if condition using shell scripts.

Let me paste the exact condition what I am looking at

if [[ "x$do_clean_flag" = "x-clean" && -z "$show_me_flag" && "$verify" = true ]]

回答1:


From "help test":

-z STRING      True if string is empty.



回答2:


-z checks whether $show_me_flag is defined

check out the manual of test(1)




回答3:


-z (something) means if (something) is NULL then return true

http://unixhelp.ed.ac.uk/CGI/man-cgi?test

suggests that zero length returns true as well, I'd suggest doing "man test" on your machine to check the exact wording on your system.



来源:https://stackoverflow.com/questions/5594039/z-option-inside-if-condition-in-shell-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!