2

I have seen on the forum that the problem is that I create octal instead of decimal, but I can't find out where to change my code to solve this.

This is part of my code:
dd=1234567890aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
ddate=$(exiv2 "${i}"|grep timestamp)
SPEC=$ddate
read X X YEAR MONTH DAY HOUR MINUTE SECOND <<<${SPEC//:/ }
d1=${YEAR:2}
d2=${dd:(MONTH-1):1}
d3=${dd:(DAY-1):1}
d4=${dd:(HOUR-1):1}
d5=${dd:(MINUTE-1):1}
d6=${dd:(SECOND-1):1}
d7=0

Thank you for the help!

Helfenstein
  • 315
  • 1
  • 4
  • 13
  • Can you do echo `echo "$SPEC" | cat -vte` and show its content here. – anubhava Feb 13 '14 at 19:25
  • possible duplicate of [bash: value too great for base (error token is "0925")](http://stackoverflow.com/questions/5455779/bash-value-too-great-for-base-error-token-is-0925) – devnull Feb 13 '14 at 19:34

1 Answers1

5

Tell bash that your variables are decimal, not octal

d2=${dd:(10#$MONTH-1):1}
d3=${dd:(10#$DAY-1):1}
d4=${dd:(10#$HOUR-1):1}
d5=${dd:(10#$MINUTE-1):1}
d6=${dd:(10#$SECOND-1):1}
glenn jackman
  • 238,783
  • 38
  • 220
  • 352