0

teams.txt:

Bills
Jets
Dolphin
Patriots

.

for team in `cat teams.txt`
do
    if ["$team" == "Bills"]
    then
        echo "$team hired Rex Ryan as coach"
    fi
    echo "$team Nation"
done

I keep getting the error:

teams.sh: line 5: [Bills: command not found

I'm not sure what I'm doing wrong with my code.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Gino
  • 1

1 Answers1

5

You are missing space around [ and ]. It should looks like this:

for team in `cat teams.txt`
do
    if [ "$team" == "Bills" ]
    then
        echo "$team hired Rex Ryan as coach"
    fi
    echo "$team Nation"
done
Artur Szymczak
  • 1,933
  • 12
  • 12