In a POSIX shell script, I'd like to use decimal numbers generated by seq -w
both in string manipulations and in simple calculations using $(( ... ))
. This breaks because numbers with leading zeroes are interpreted as octal numbers. I have come up with something like this to actually get decimal numbers...
for n in $(seq -w 0 300); do
str="xxx $n"
dec=$(echo $n | sed -e 's,00*\(..*\)$,\1,')
...
done
... but I wonder if there's an easier / more obvious way to do this.