View Single Post
Posts: 2,802 | Thanked: 4,491 times | Joined on Nov 2007
#11
Originally Posted by jamiefuller View Post
any chance of a code snipet as to how to remove the trailing zero?
You can use a pattern expansion:
Code:
a=$(( ( a * 60) + ${x#0} ))
Or just a better way of doing what I'm doing =)
No forks, and unrolling the loop for simplicity:

Code:
IN=00:08:19.12
IFS=: read h m s <<EOF
${IN%%.*}
EOF

a=$(( ${h#0} * 3600 + ${m#0} * 60 + ${s#0} ))
Quick'n'dirty hack (ab)using date:

Code:
date -u -d 1970.01.01-${IN%%.*} +%s
(Note: the input date format is highly non-portable)
 

The Following 4 Users Say Thank You to lma For This Useful Post: