Shell script “for” loop syntax

前端 未结 11 954
攒了一身酷
攒了一身酷 2020-12-07 07:11

I have gotten the following to work:

for i in {2..10}
do
    echo \"output: $i\"
done

It produces a bunch of lines of output: 2

11条回答
  •  渐次进展
    2020-12-07 08:04

    Well, as I didn't have the seq command installed on my system (Mac OS X v10.6.1 (Snow Leopard)), I ended up using a while loop instead:

    max=5
    i=1
    
    while [ $max -gt $i ]
    do
        (stuff)
    done
    

    *Shrugs* Whatever works.

提交回复
热议问题