The shell script reported an error: not sure operator expected

A statement like this is used when matching strings

if[  $ timeofday  = ” yes”];   then

   echo  ” Good   morning”

   exit   0

The reason for the error is: if the value of the variable timeofday is empty, the if statement becomes if  [  =” yes”  ], This is not a legal condition. To avoid this, we must quote the variable if  [ “$ timeofdat”=”yes”  ], In this way, even null variables provide legal test conditions, if  [  ” “=” yes”   ]

Similar Posts: