22

I've been looking everywhere for what should be a simple example. First time trying to script something for zsh now that MacOS has switched over to it as default - how do I compare two strings in an if statement? I tried the following but continue to receive the error no matches found: [foo==foo]

if ["foo"=="foo"]
then
    echo "True"
else
    echo "False"
fi

1 Answers1

21

How do I compare two strings in an if statement?

Use the following:

if [[ "foo" == "foo" ]] 
DavidPostill
  • 162,382