samedi 10 juillet 2021

Trying to compare characters in shell script but I'm getting an error

Why isn't this if-else operation working? I fixed my spacing many times yet getting the error syntax error near unexpected token `elif' , I have tried using "==" instead of "=", I have tried using two third brackets but nothing seems to work.

if [ "$operation" = "+" ]
  then addition()
elif [ "$operation" = "-" ]
  then subtraction()
elif [ "$operation" = "*" ]
  then multiplication()
elif [ "$operation" = "/" ]
  then division()
fi

Aucun commentaire:

Enregistrer un commentaire