BASH let command..gives wrong result on padded numbers -
the following code prints 4 expected:
let x=21 let x=$x-1 echo $x
but following prints 16:
let x=000021 let x=$x-1 echo $x
could explain difference?
00021 octal constant. output 16 correct decimal result. octal value use
printf "%o\n" $x
remove leading zeros if number decimal.
Comments
Post a Comment