LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   meaning of if [ -z $SOMETHING....] in bash shell (https://www.linuxquestions.org/questions/linux-newbie-8/meaning-of-if-%5B-z-%24something-%5D-in-bash-shell-575803/)

darwinianlo 08-09-2007 01:17 AM

meaning of if [ -z $SOMETHING....] in bash shell
 
Hi,
I have the following in a bash script file if [ -z "$SOMETHING" ]
I have searched for the -z option for an hour in Bash References, every other option is covered except for '-z' I assume this means is $SOMETHING defined in the environment but can anyone give me a definitive answer.

unSpawn 08-09-2007 01:21 AM

I applaud you searching around but "man test" is what you're looking for (string with length zero).

darwinianlo 08-09-2007 02:37 AM

I never would have guessed 'man test', but surprised I couldn't google for if [ -z,

thanks for the help.

chrism01 08-09-2007 03:21 AM

To google it you'd prob need single quote marks around that.

Daws 08-09-2007 06:05 AM

"man [" would have worked too.

syg00 08-09-2007 06:35 AM

And people wonder why *nux is considered not newbie friendly ...
For the greater proportion of the human race, that is just too arcane.

colucix 08-09-2007 08:57 AM

Quote:

Originally Posted by syg00
For the greater proportion of the human race, that is just too arcane.

Not if a newbie had the patience to read a good beginners' guide! ;)

student04 08-09-2007 10:34 AM

Quote:

Originally Posted by darwinianlo
Hi,
I have the following in a bash script file if [ -z "$SOMETHING" ]
I have searched for the -z option for an hour in Bash References, every other option is covered except for '-z' I assume this means is $SOMETHING defined in the environment but can anyone give me a definitive answer.

Example 7-2 in
http://www.tldp.org/LDP/abs/html/testconstructs.html

rupertwh 08-09-2007 11:02 AM

Quote:

Originally Posted by syg00
For the greater proportion of the human race, that is just too arcane.

I would hazard a guess that "the greater proportion of the human race" isn't involved in shell scripting at all. Which kind of makes your point moot.


All times are GMT -5. The time now is 04:17 AM.