7
rated 0 times
[
7]
[
0]
/ answers: 1 / hits: 23176
/ 2 Years ago, tue, june 7, 2022, 2:54:31
As far as I know, bash variables do not have a certain type.
My problem is, I need to convert a time stamp (always in format: hh:mm:ss
) to a single integer representing seconds.
So I cut the hh
, mm
and ss
parts into separate strings and use expr
to calculate the seconds integer like:
TIME=expr $HH * 3600 + $MM * 60 + $SS
But when e.g. $HH=00
then expr won't work. Is it possible to convert strings like 00
or 01
to integers?
More From » bash