1826212 Members
2494 Online
109691 Solutions
New Discussion

For loop

 
SOLVED
Go to solution
Piotr Kirklewski
Super Advisor

For loop

Hi there
I have a simple loop

#! /sbin/sh

for i in 1 2 3 4 5 6 7 8 9 10
do
echo $i
done

The thing is, i nead this command to be repeated 1000 times.

Is there any way to do this without puting 1 2 3 ... 1000 ?

Cheers

Jesus is the King
4 REPLIES 4
Peter Godron
Honored Contributor
Solution

Re: For loop

Hi,
don't know about for loop, but with while:
#!/usr/bin/sh
i=1
while [ $i -le 1000 ]
do
echo $i
i=`expr $i + 1`
done
Peter Godron
Honored Contributor

Re: For loop

Hi (again),
after some searching !

Or you change shell, please see:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=186099

Oviwan
Honored Contributor

Re: For loop

Hey

integer i = 1

while ((i<=1000))
do
echo ${i}
i=((${i+}1))
done

Don't forget to assign points, also in your earlier threads!

Regards
Piotr Kirklewski
Super Advisor

Re: For loop

Cool
Thank you
Jesus is the King