算術求部分在bash手冊列出:bash中的變量post-increment/decrement和pre-increment/decrement之間有什麼區別?以下等運營商
id++ id--
variable post-increment and post-decrement
++id --id
variable pre-increment and pre-decrement
據我瞭解,++x
和--xx
增加或進行其他操作之前減少變量?例如x++
:
$ x=5; echo $((++x/2))
3
$ x=5; echo $((x++/2))
2
$
然而,當x++
和x--
有用嗎?一般來說,bash中變量後期增加/減少和前期增加/減少之間的區別是什麼?
您已經確定了區別,那麼這裏有什麼問題? –