问题
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