In any POSIX shell, you can prevent a number from being considered octal by stripping its leading zeros with a combination of the ${var#prefix} and ${var%%suffix} expansion forms:
BN=001002; BN=$(( ${BN#${BN%%[!0]*}} + 1 )); echo "$BN"
1003
In shells which support the ${var//pat/repl} syntax, you can also do that by prepending it a 1 and subtracting it from 10^{number_of_digits}:
BN=000012; BN=$(( 1$BN - 1${BN//?/0} )); echo "$BN"; BN=$((BN+1)); echo "$BN"
12
13
This works in bash, zsh, ksh93, mksh and yash.
In bash, ksh93 and zsh (but not in yash and mksh) you can also use the fortranish ** operator (exponentiation):
BN=000012; BN=$(( 1$BN - 10**${#BN} ))
catprogram. The ideal answer would combine both. (The ideal answer would also use"%.3d\n"format rather than the old leading 0 trick, which is ancient style, and misleading because in that case the leading 0 doesn't mean octal.).3dbetter than03d? Apart from the octal confusion....3dmakes the intent much more obvious: An optional precision that gives the minimum number of digits to appear for the d, i, o, u, x, and X conversion specifiers. The03dsyntax dates back to the original 1970s version, and preserving backward compatibility has made its rules extremely complicated.