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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable explanation x$var=x

Status
Not open for further replies.

AnotherAlan

Technical User
Feb 10, 2006
362
GB
Guys,

I have seen this construct in a number of our scripts but have no idea what the final value should be. Can someone provide an explanation please.

I do understand the test and the variable assignments, just not the x$RET = x part. What does x represent?
All help very much appreciated.

RET=`$RCMD $TGT_HOST date 2>/dev/null`
if [[ x$RET = x ]]; then

Thanks
Alan
 
Hi,

This is a trick for testin if a variable is NULL because some old versions of shells cannot use "" to delimit a NULL string. You can use any character you want not only x
these tests ar equivalent

Code:
if [ "$RET" = "" ]
then
 print '$RET is empty'
fi

if [ z$RET = z ]
then
 print '$RET is empty'
fi

 
Excellent, thanks very much for the info aau.
Much appreciated.
Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top