Chris Down wrote:
> On 2013-03-18 00:46, Linda Walsh wrote:
>> Bruce Dawson wrote:
>>> Chris Down pointed that out. My loop now looks like this -- portable (I
>>> believe) and fast:
>>>
>>> BashCount() {
>>>     for (( i = $1 ; i > 0 ; i-- )); do
>>>         :
>>>     done
>>>     echo Just did $1 iterations using bash math
>>> }
>> ----
>> To do the above, you'd want to pre-init
> 
> There is no need to preinitialise the variable, I'm not sure why you think it 
> is
> necessary.

the above pre-inits "i to $i" before the loop.

If you want to make the loop portable, it seems some variation on
while would be necessary, thus the need to pre-init the value to the
count before going into the while, maybe:


n=10;while [ $((n-=1)) != 0]; do echo $n;done




Reply via email to