help-bash
[Top][All Lists]
Advanced

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

Re: SECONDS=0 does not reset SECONDS, or I'm missing something


From: Andreas Kusalananda Kähäri
Subject: Re: SECONDS=0 does not reset SECONDS, or I'm missing something
Date: Thu, 4 Jun 2020 16:45:28 +0200

On Thu, Jun 04, 2020 at 09:58:39AM -0400, Greg Wooledge wrote:
> On Thu, Jun 04, 2020 at 03:52:50PM +0200, Andreas Kusalananda Kähäri wrote:
> > I might have been a bit imprecise in describing my issue.
> > 
> > Most of the time, removing the directories takes less than a second.
> > For these cases, I don't want to execute the sleep at all.  Only when a
> > call to rm takes more than one second do I want to sleep.
> 
> So, use "time rm ..." with the TIMEFORMAT variable set how you like.
> Capture the output of time into a variable (trickier than it sounds),
> and then sleep only if the variable does not match 0.* .
> 
> See <https://mywiki.wooledge.org/BashFAQ/032> for help capturing time's
> output.

This is most useful, thanks!  Yes, getting the time out of the time
keyword is a bit of a hassle, but it's good to see that it's doable, and
my initial tests works as expected.

I might possible submit a documentation patch against bash later, if I
remember, or I'll add it to my long list of TODO items, for a rainier
day.

-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.



reply via email to

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