Command Line - if syntax error

https://www.codecademy.com/paths/web-development/tracks/learn-the-command-line/modules/bash-scripting/lessons/learn-bash-scripting/exercises/conditionals

I am stuck in this step for some time, I have followed the instructions but couldn’t get it to work.

if [ condition]
then
  echo xxx
else
  echo xxx
fi

Why do it keep saying “fi” is syntax error?
Also I have to add set ff=unix otherwise the command output will say bad interpreter

Usually that would mean it doesn’t recognize that as a command…
I don’t know what code language you are using, but did you spell your command on line 11 incorrectly or use it wrong?

I think it works now! Apparently there seems to be a bug that the online bash environment doesn’t recognise the script. I reported the bug and it works perfectly :slight_smile:

1 Like