Iterating through a range of ints in ksh?

后端 未结 7 389
故里飘歌
故里飘歌 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:31

    seq - but only available on linux.

    for i in `seq 1 10`
    do 
        echo $i
    done
    

    there are other options for seq. But the other solutions are very nice and more important, portable. Thx

提交回复
热议问题