![if/then `cat`を使ったループ[繰り返し]](https://linux33.com/image/83792/if%2Fthen%20%60cat%60%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%9F%E3%83%AB%E3%83%BC%E3%83%97%5B%E7%B9%B0%E3%82%8A%E8%BF%94%E3%81%97%5D.png)
チーム.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