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
  • 66,199
  • 35
  • 114
  • 250
Gino
  • 1
  • 1
  • 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,913
  • 12
  • 12