Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: repeat count?



2023-01-16 19:05:21 +0100, Dominik Vogt:
> Is it possible to get the pass number of a repeat loop from within
> the loop, or is it necessary to use a hand written counter?
> 
>   repeat 10; do
>     echo "pass number ???"
>   done
[...]

You can always do:

n=0; repeat 10 echo pass number $((++n))

Or a la ksh93

for ((n=1;n<=10;n++)) echo pass number $((++n))

-- 
Stephane




Messages sorted by: Reverse Date, Date, Thread, Author