LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   bash script loop (http://www.linuxquestions.org/questions/programming-9/bash-script-loop-363400/)

bong.mau 09-14-2005 03:48 PM

bash script loop
 
hi

i'm new to linux...

i 'm building a bash script to automate some jobs & commands....
i need to check n times a condition and then exit...
the below example i think will repeat a cycle 5 times.....
___________________
for i in 1 2 3 4 5
do
echo "Welcome $i times"
done
_______________________

then does not matter what instructons i will put insiede the do - done
delimiters....

now the question...if i have to repeat a loop to check a condition 100 times
what is the syntax ?
i have to specify all the numbers from 1 to 100 in the for instruction
or there is something like..... "for 1 to 100"
then in another thread i opened ,it was suggested me to learn about
script looking into some guides....
these guides are useful,but i still have not found a reference guide of the
bash script language....
a reference where i can look to the "for" instruction and see the syntax ....
sumarizing ....... i need to know if there is a simplier syntax about the
sample code to repeat 100 times...and if there is a reference book about bash script language..a book where all the instruction are listed in alphabetical order...
thanks in advance

Maurizio

bong.mau 09-14-2005 03:54 PM

to be more clear
i need to check if pgm is startet
the check must be repeated 5 times
for ..... (repeat 5 times)
do
sleep 2
ps -e | grep pppd
done

david_ross 09-14-2005 03:56 PM

You can use this syntax too:
for((i=0;$i<=100;i=$(($i+1))));do
echo $i
done

bong.mau 09-14-2005 04:00 PM

hi

david i think my example in the forst update is misleading.....(sorry ..i done a mistake putting this example i find on internet site....)
really what i need is to repeat n times the loop in the second post

david_ross 09-14-2005 04:15 PM

Just use 5 rather than 100 then.

Dave Kelly 09-14-2005 06:09 PM

http://www.linuxlinks.com/Software/U...ts/index.shtml
http://shamrockshire.yi.org/scripts.html
http://martin.f2o.org/linux/?offset=480
http://javascript.internet.com/
http://atthefaire.com/cgi-bin/ib31/i...=powered+rides
http://www.linuxvoodoo.com/resources...debugging.html

chrism01 09-14-2005 07:38 PM

http://www.tldp.org/LDP/abs/html/index.html
http://www.faqs.org/docs/bashman/bashref.html#SEC_Top
http://rute.2038bug.com/index.html.gz
http://www.usc.edu/~lhl/tutorials/unix/


All times are GMT -5. The time now is 09:49 AM.