Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about K Shell

Status
Not open for further replies.

microsky

MIS
May 7, 2001
33
Please see following K shell command, in the IF statement, why the result is same when use "-z" and "-n" parameter?

$ set |grep SHELL
SHELL=/bin/ksh
$ set |grep FILE_NAME
FILE_NAME=''
$ if [ -n $FILE_NAME ] ;
> then
> echo "fa"
> fi
fa
$ if [ -z $FILE_NAME ] ;
> then
> echo "fa"
> fi
fa
$
 
Think you need some quotes round the $FILE_NAME to ensure that it gets treated as a string.
 
Thank you very much!
I changed as following, it is right.
$if [ -n "$FILE_NAME" ] ;
> then
> echo "fa"
> fi
$
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top