Articles

for loop for n times in ksh.

June 24, 2011 at 11:05:54
Specs: AXI 5.3L, 10

Hi,

Can I perform 'for loop' based on input parameter in ksh?.
Meaning, if I give 4, the script should loop for 4 times. If I give 10, it should be able to loop for 10 times. Basically, I am trying to automate the AWR report generation for oracle databases.
Please help.

Thanks
Suresh

sureshht


See More: for loop for n times in ksh.

Report •


#1
June 24, 2011 at 13:35:37

A way .....

#!/bin/ksh

if [ $# -ne 1 ]
then
   echo "need a loop counter"
   exit
fi

# no error checking
counter=$1
a=0
while [ $a -lt $counter ]
do
   ((a+=1))  # another way of saying    ((a=a + 1))
   echo "looping: $a"
done


Report •

#2
June 27, 2011 at 13:47:22

Hi nails,

Thank you very much. It worked for me.

Thanks and Regards
Suresh

sureshht


Report •

Related Solutions


Ask Question