bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug/limitation in 'time'


From: Linda Walsh
Subject: Re: Bug/limitation in 'time'
Date: Mon, 18 Mar 2013 00:46:51 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666


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
(I'd use i=${1:?"need start count"} in bash, but don't know if that is portable)

so, assuming I know i is > 0:
i=$1; while $((i-=1)); do :; done






reply via email to

[Prev in Thread] Current Thread [Next in Thread]