[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can Bash do simple math?
From: |
alex xmb sw ratchev |
Subject: |
Re: Can Bash do simple math? |
Date: |
Tue, 6 Aug 2024 18:21:26 +0200 |
On Tue, Aug 6, 2024, 17:39 Bash-help via <help-bash@gnu.org> wrote:
> On 6 August 2024 17:12:20 CEST, alex xmb sw ratchev <fxmbsw7@gmail.com>
> wrote:
>
> i mean , the input must be x 60 .. hmm ? i dont see such
>
> On Tue, Aug 6, 2024, 17:11 alex xmb sw ratchev <fxmbsw7@gmail.com> wrote:
>
> i missed a few question marks .. sorry ..
>
> On Tue, Aug 6, 2024, 17:08 alex xmb sw ratchev <fxmbsw7@gmail.com> wrote:
>
> ah its like array matching .. uh i had nice awk script , ill make new ..
>
> so the % 60 or so code is * 60 ..
> weird
>
> a number , big , prolly smaller than bash max ?
> then thats already seconds
>
> it implents a ' pseudo 60 ' case
> where in end to * 60
>
> i really dont see why 60
>
> The use case for this piece if code is taking two outputs from `date +%s`
> i.e. seconds from start of UNIX time and calculate the time elapsed between
> them. This would be numbers in the size range 1722957897. The difference
> value can then be converted by the discussed piece of code to output a
> string on the format "hours:minutes:seconds". The conversion happens as
> earlier explained by Greg and make use of the different mathematical
> properties of the modulus operator (`%`) and integer division (`\`).
>
i try again ..
date +%s is seconds
newseconds minus oldseconds is valid basic time math
but applying % 60 to this seconds , will returm minutes
again , diff is seconds , cause %s only
so seconds = ( diff_in_seconds % 60 ) is fully invalid
<https://en.m.wikipedia.org/wiki/Modulo>
> <https://en.m.wikipedia.org/wiki/Remainder>
>
- Re: Can Bash do simple math?, (continued)
Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
Re: Can Bash do simple math?, Greg Wooledge, 2024/08/06
Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
Re: Can Bash do simple math?, bash, 2024/08/06
Re: Can Bash do simple math?, Greg Wooledge, 2024/08/06
Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06