Simple way to convert HH:MM:SS (hours:minutes:seconds.split seconds) to seconds

前端 未结 12 1819
走了就别回头了
走了就别回头了 2021-01-31 16:40

What\'s an easy way to convert 00:20:40.28 (HH:MM:SS) to seconds with a Bash script?

Split seconds can be cut out, it’s not essential.

12条回答
  •  无人共我
    2021-01-31 17:23

    If you are processing a time from ps, mind you that the format 2-18:01 is also possible for 2 days, 19 hours, 1 minute. In that case you'll want to checkout: Parse ps' "etime" output and convert it into seconds

提交回复
热议问题