To force numbers to be interpreted in base10, you can prefix with 10#. Specifically 10#08 and 10#09 will be interpreted as valid decimal numbers, and not invalid octal numbers. (I'm taking the output of date +%S
)
However, it seems I then can't use the variable in comparisons:
x=10#08
y=10#20
echo $((x+y)) // (returns 28, as expected)
while [ $x -lt $y ]
do
x=$((x++))
done
gives me the error
-bash: [: 10#08: integer expression expected
Is this a bug in bash?