I'm trying to work out the difference in 2 unix times to do a simple calculation (in a shell script) but it doesn't seem to work.
I have set 2 variables one called
$d
and the other $c
.
Here's the syntax i currently have for setting up the variables:
c= echo $a | awk -F : '{print ($1 * 32140800) + ($2 * 2678400) + ($3 * 86400) + ($4 * 3600) + ($5 * 60) }'
echo $c
d= echo $a | awk -F : '{print ($1 * 32140800) + ($2 * 2678400) + ($3 * 86400) + ($4 * 3600) + ($5 * 60) }'
echo $d
(variables a and b simply receive the timestamp from another script)
I'm trying to subtract the output of $c
from $d
but every method I have used doesn't seem to work.
I've tried the following:
1)
duration=$(echo "$d - $c")
echo $duration
2)
duration=$((d-c))
echo $duration
Asked by SSR
(25 rep)
Nov 7, 2019, 12:20 PM
Last activity: Nov 7, 2019, 01:22 PM
Last activity: Nov 7, 2019, 01:22 PM