Exe 4.1: unary operator expected error

I’m getting an error in exe 4.1 of linux for robotics course. I went through articles here but didn’t find any understandable solution. I tried [[ ]] which I searched from stackoverflow. It solved the error issue but then there was no output. My queries are:

  1. Why is it giving this error?
  2. How to get the output simulation?

Thank you
Abdul Basit

Hi @abdulbasitisdost,

the error happens normally when you are checking an empty variable.

Instead of using if [[ $VAR_NAME = "SOME_VALUE" ]]; try putting $VAR_NAME inside double quotes. Example:

if [[ "$VAR_NAME" = "SOME_VALUE"  ]]; then
   echo YES; 
else
   echo NO; 
fi

Oo. Okay thank you for sharing that sir