I am running some gnu time scripts which generates output of the form
mm:ss.mm (minutes, seconds and miliseconds, for example 1:20.66)
or hh:MM:ss (hours, minutes and seconds, for example 1:43:38).
I want to convert this to seconds (in order to compare them and plot them in a graphic).
Which is the easiest way to do this using bash?
Assuming you can run the GNU
datecommand:If the script is generating “mm:ss.mm” you’ll need to add “00:” to the beginning, or
datewill reject it.If you’re on a BSD system (including Mac OS X), you need to run
date -j +'%s' "0143.38"unless you have GNU date installed with MacPorts or Homebrew or something.