`cat` を使用した if/then ループ

`cat` を使用した if/then ループ

チーム.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

次のエラーが繰り返し発生します:

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

自分のコードで何が間違っているのか分かりません。

答え1

[ と ] の前後にスペースがありません。次のようになります。

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

関連情報