LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 08-09-2007, 01:17 AM   #1
darwinianlo
LQ Newbie
 
Registered: Aug 2007
Posts: 13

Rep: Reputation: 0
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.
 
Old 08-09-2007, 01:21 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,524
Blog Entries: 51

Rep: Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601
I applaud you searching around but "man test" is what you're looking for (string with length zero).
 
Old 08-09-2007, 02:37 AM   #3
darwinianlo
LQ Newbie
 
Registered: Aug 2007
Posts: 13

Original Poster
Rep: Reputation: 0
Smile

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

thanks for the help.
 
Old 08-09-2007, 03:21 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994
To google it you'd prob need single quote marks around that.
 
Old 08-09-2007, 06:05 AM   #5
Daws
Member
 
Registered: May 2006
Location: UK
Distribution: Debian, Linux From Scratch
Posts: 416
Blog Entries: 1

Rep: Reputation: 30
"man [" would have worked too.
 
Old 08-09-2007, 06:35 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,796

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
And people wonder why *nux is considered not newbie friendly ...
For the greater proportion of the human race, that is just too arcane.
 
Old 08-09-2007, 08:57 AM   #7
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,361

Rep: Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909Reputation: 1909
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!
 
Old 08-09-2007, 10:34 AM   #8
student04
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: OS X, CentOS
Posts: 669

Rep: Reputation: 34
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
 
Old 08-09-2007, 11:02 AM   #9
rupertwh
Member
 
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 292

Rep: Reputation: 46
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.
 
  


Reply

Tags
option


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
own shell in place of bash shell somu_thedev Programming 6 07-31-2007 10:13 AM
Run a C Shell using only Bash shell HSN Linux - Software 1 12-25-2006 07:44 AM
"^" meaning in perl/shell script? fhleung Programming 8 01-03-2006 07:27 PM
'./file' meaning in python & shell script Chowroc Programming 7 12-30-2005 02:32 AM
Bash Shell triplem Linux - Software 4 04-17-2003 05:11 PM


All times are GMT -5. The time now is 11:19 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration