Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下代码按预期打印 4:
let x=21 let x=$x-1 echo $x
但以下打印 16:
let x=000021 let x=$x-1 echo $x
有人可以解释其中的区别吗?
00021 是八进制常数。输出 16 是正确的十进制结果。要获得八进制值,请使用
printf "%o\n" $x
如果数字是十进制,则删除前导零。