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

Popular posts from this blog

python - cx_oracle unable to find Oracle Client -

shader - OpenGL Shadow Map -

c# - Exchange 2010/2013 TransportAgent Content Conversion for Internal Recipients -