b***l 发帖数: 15 | 1 In this script:
for i in 1 2 3 4; do echo $i; done
It will print 1 2 3 4. But if I want to loop from 1 to N which is very large,
e.g, 100000, how to do that in bash or ksh using "for" loop? Is there anything
like "for i in 1:10000"? This one does not work.
3x | f********h 发帖数: 149 | 2 you can increase i by i=`expr $i + 1`
【在 b***l 的大作中提到】![](/moin_static193/solenoid/img/up.png) : In this script: : for i in 1 2 3 4; do echo $i; done : It will print 1 2 3 4. But if I want to loop from 1 to N which is very large, : e.g, 100000, how to do that in bash or ksh using "for" loop? Is there anything : like "for i in 1:10000"? This one does not work. : 3x
| b***l 发帖数: 15 | 3 I used this approach in a while loop to do the same thing. But I am wondering
if there is a short cut other than this way.
Thanks any way.
large,
anything
【在 f********h 的大作中提到】![](/moin_static193/solenoid/img/up.png) : you can increase i by i=`expr $i + 1`
| c*****t 发帖数: 1879 | 4 nope. That was the standard approach :)
【在 b***l 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I used this approach in a while loop to do the same thing. But I am wondering : if there is a short cut other than this way. : Thanks any way. : : large, : anything
|
|