Tuesday, November 8, 2011

AIX scripting, loop iterations on integers

I usually work with ksh, but this might work for other shells as well?

 for i in 1 2 3 4 5 6 7  
 do  
 #stuff  
 done  

while loop over number range:
 counter=0  
 max=50  
 while [ $counter -lt $max ]  
 do  
 # stuff  
 let counter=$counter+1  
 done  

where some of the ideas orginated from:
http://stackoverflow.com/questions/1591109/how-can-i-iterate-through-a-range-of-ints-in-ksh