help-bash
[Top][All Lists]
Advanced

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

Re: was there a more fine number than $SECONDS for the same purpose


From: Tapani Tarvainen
Subject: Re: was there a more fine number than $SECONDS for the same purpose
Date: Sun, 7 Nov 2021 15:34:12 +0200

On Sun, Nov 07, 2021 at 08:17:56AM -0500, Greg Wooledge (greg@wooledge.org) 
wrote:

> You can store the value of EPOCHREALTIME in a different variable at the
> start of your script, and then retrieve it again later on, and subtract
> the two.  However, subtracting the two values will require forking an
> external program, because bash can't do it.

Well bash can do it, if you save the values as microseconds.
$EPOCHREALTIME always has six decimal points, it doesn't omit
trainling zeroes, so it's pretty easy. E.g.,

START=${EPOCHREALTIME/[[:punct:]]/}
...
NOW=$(( ${EPOCHREALTIME/[[:punct:]]/} - START ))

-- 
Tapani Tarvainen



reply via email to

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