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
  • 172,303
  • 28
  • 230
  • 274
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
  • 497,756
  • 71
  • 530
  • 681
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,962
  • 3
  • 21
  • 43