I have a fixed length string which is a number. When I assign the string to a variable it is getting assigned 8 instead of 10. Why? How do I stop it?
$ i=10
$ ((i=i+1))
$ echo $i
11 # Right answer
$ i=000010
$ ((i=i+1))
$ echo $i
9 # Wrong answer
Update: The answers confirm that the number is being converted to octal and that the leading zeros need to be removed. Here is the sed command for that.
echo "000010" | sed 's/0*//'