help-bash
[Top][All Lists]
Advanced

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

Re: Can Bash do simple math?


From: Bash-help
Subject: Re: Can Bash do simple math?
Date: Tue, 06 Aug 2024 17:32:37 +0200
User-agent: K-9 Mail for Android

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 (`\`). 

<https://en.m.wikipedia.org/wiki/Modulo>
<https://en.m.wikipedia.org/wiki/Remainder>


reply via email to

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