On Tue, 23 Sep 2025 11:52:56 -0400, Greg Wooledge wrote:
> > Of course, I can see how this can be used for playing some practical jokes,
> > even on yourself. I would much rather if there is an easy way to make time
> > take a -n N option instead.
>
> That's more acceptable than a new special variable, in my opinion. However,
> I don't think either one is really needed. You can already do
>
> time for ((i=1; i<=100; i++)); do my command here; done
>
> or write a repeat (with eval) function, and do something like
>
> time repeat -e 100 'my command here'
No, it it not a "special" variable, it is a regular shell variable, if it
exists at all.
And, that's a lot of typing you just did for something that could be simply
accomplished by:
time -100 'my command (with redirections) here'
But more importantly, with or without eval, no shell function can properly
parse the remaining pipeline.
Anyway, I think the ability of the time command to execute something multiple
times and then measure the total elapsed time is interesting, so I posted it
for anyone who might also find it interesting. Take it or leave it. As you
see, I am the first one to admit that it is not perfect.