0

このような単純なスクリプトが機能しないのはなぜですか?

  1 for i in {1..6}
  2 do
  3     if[ "$i" -lt "3" ]
  4     then
  5         echo "a"
  6     else
  7         echo "b"
  8     fi
  9 done

また

  1 for i in {1..6}
  2 do
  3     if[ "$i" < 3 ]
  4     then
  5         echo "a"
  6     else
  7         echo "b"
  8     fi
  9 done

エラー:

./test.sh: line 4: syntax error near unexpected token `then'
./test.sh: line 4: `    then'
4

1 に答える 1

13

ifと の間にはスペースが必要です[

于 2013-05-26T04:07:36.433 に答える