I have a shell script with a variable that is set to "date +%s" and I have the timestamp of a file.
Now I want the script to calculate now-timestamp and then use the modulus (%) to calc the time elapsed. Like this:
Code:
NOW=`date +%s`
TS=1102922460
tmp = now-ts
s = tmp%60
tmp -= s
tmp /= 60
m = tmp%60
tmp -= m
tmp /= 60
h = tmp%24
tmp -= h
tmp /= 24
days = tmp
echo elapsed $days days, $h:$m:$s
How can I calc this in a shell script?