0

How do I fix this? It just skips the if statement. I am trying to do an if statement that finds if the group entered meets the right criteria.

if $groupchosen== "student"; then
Avinash Raj
  • 166,785
  • 24
  • 204
  • 249
N.Name
  • 1

2 Answers2

2

The if statement requires a command, not a bare comparison. Use test (or its alias, [).

if [ "$groupchosen" = 'student' ] then
chepner
  • 446,329
  • 63
  • 468
  • 610
Federico Govoni
  • 148
  • 4
  • 9
0

I would suggest giving this a look. But long story short:

if [ "foo" = "foo" ]; then
    echo expression evaluated as true
fi
Moises Jimenez
  • 1,942
  • 3
  • 19
  • 43