3

I have some problem while reading a file with numbers, when the number is '09' or '08'.

The string I read loks like 0:09.21 this. It's a time value. I want to calculate the ms of this value. Wenn cutting the '09' I got the error:

declare: 09: value too great for base (error token is "09")

my bash code looks like this:

declare -i j=$(echo $i | cut -c 3-4)

How can I avoid, that it gets interpreted as octal?

RoQuOTriX
  • 2,871
  • 14
  • 25
  • 1
    `declare -i j=$((10#$(echo $i | cut -c 3-4)))` as per https://stackoverflow.com/questions/12821715/convert-string-into-integer-in-bash-script/12821845#12821845 – Robert Jan 30 '18 at 17:10

0 Answers0