[plug] How to check for an empty string in a bash script.

Anthony J. Breeds-Taurima tony at cantech.net.au
Wed Dec 15 10:57:02 WST 1999


On Wed, 15 Dec 1999, Buddrige, David wrote:

> 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

if [ -n "$THE_PATH" ] ; then
	echo the path contains data
fi

if [ -z "$THE_PATH" ] ; then
	echo the path is empty
fi


Yours Tony.



More information about the plug mailing list