syntax of for loop in linux shell scripting

前端 未结 4 1777
故里飘歌
故里飘歌 2020-12-03 05:39

I have a problem implementing a for loop. I get this error when I execute my script

test1.sh: 2: Syntax error: Bad for loop variable

4条回答
  •  无人及你
    2020-12-03 05:58

    A standard POSIX shell only accepts the syntax for varname in list

    The C-like for-loop syntax for (( expr1; expr2; expr3 )) is a bashism.

    You can get similar behavior in the standard POSIX shell using for c in $(seq 1 5)

提交回复
热议问题