Iterating through a range of ints in ksh?

后端 未结 7 489
故里飘歌
故里飘歌 2020-12-30 22:51

How can I iterate through a simple range of ints using a for loop in ksh?

For example, my script currently does this...

for i in 1 2 3 4 5 6 7
do
            


        
7条回答
  •  不思量自难忘°
    2020-12-30 23:18

    ksh93, Bash and zsh all understand C-like for loop syntax:

    for ((i=1; i<=9; i++))
    do
        echo $i
    done
    

    Unfortunately, while ksh and zsh understand the curly brace range syntax with constants and variables, Bash only handles constants (including Bash 4).

提交回复
热议问题