: unary operator expected

Hiya all,
Why do I get a :unary operator expected when I try to put a condition statement in my shell script (sh) like so and how to fix?

if [$1 = "mystring" ]; then
 
echo "say hello"
 
else
 
echo "don't say hello"
 
fi

? It seems if the script receives an argument it works but if I don't put an argument I get this error?

By putting a space between [ and $1 .

Hi.

You're missing a space after [. And you should always quote input parameters and variables, especially if you don't know whether they are set / exist. Quoting literal strings / values is a question of preference.

if [ "$1" = mystring ]; then

just tried it but still get the same message. its almost as if it doesn't like it when I don't input an argument?

Hi Cyber,

By executing the above code
o/p was dont say helo..what u need exact o/p...