help-bash
[Top][All Lists]
Advanced

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

Re: Duration between two time stamps


From: ikhxcsz7y xmbott
Subject: Re: Duration between two time stamps
Date: Thu, 19 Aug 2021 18:03:23 +0200

LANG=C
a+=( $EPOCHREALTIME )
cmd
a+=( $EPOCHREALTIME )
r=$( bc <<<${a[1]}-$a )
printf 'res time: %s\n' $r

On Thu, Aug 19, 2021, 17:26 hancooper <hancooper@protonmail.com> wrote:

> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, August 19, 2021 2:47 PM, Chet Ramey <chet.ramey@case.edu>
> wrote:
>
> > On 8/19/21 1:10 AM, Tapani Tarvainen wrote:
> >
> > > Incidentally, why does ${var:offset} with a negative offset result in
> > > an empty string when the variable is shorter than the offset? E.g.,
> > > x=abc
> > > echo ${x: -6}
> > > I find that counterintuitive,
> >
> > Why? It's an out-of-bounds error.
> >
> > > and it'd actually be useful to
> > > be able to get "at most N characters from the end".
> >
> > If you want that, you can use ${#x} to get the length and work from
> there.
>
> Why does the following EPOCHREALTIME computation not work ?
>
> ta=$( $EPOCHREALTIME | tr ',' '.' )
> grep ...
> tb=$( $EPOCHREALTIME | tr ',' '.' )
> dt=$( ${tb}-${ta} | bc )
> printf '%s\n' "ta:$ta | tb:$tb | dt: $dt"
>
> Thank you
>
>
>
>


reply via email to

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