[plug] How to check for an empty string in a bash script.
    Buddrige, David 
    david.buddrige at mitswa.com.au
       
    Wed Dec 15 10:44:33 WST 1999
    
    
  
Hi all, 
I have the following code in a bash script that I am writing...
if [ THE_PATH="" ]; then
	echo "The Path is:" $THE_PATH
	echo "FAIL! FILE DOES NOT EXIST."	
fi
In another part of the script, the variable "THE_PATH" is populated with a
filename that is the result of a search of the filesystem.  If the file was
not found that value should be empty.  However, when I run this code, it is
printing out the filename for which I searched (indicating that the variable
"THE_PATH" is NOT empty, yet still it is making into the TRUE part of this
if statement and subsequently echoing "FAIL! FILE DOES NOT EXIST."
My question:  How does one check a variable in a bash script to see if it is
empty?
Thanks in advance for any assistance rendered....
cheers
David Buddrige
Software Engineer
david.buddrige at mitswa.com.au 
    
    
More information about the plug
mailing list