declare -i n 和 arithmetic evaluation

declare -i n 和 arithmetic evaluation

以前不知道, 今天刚看见的:
引用:
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; declare -i n
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; n=2
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; echo $n
2
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; n=2*n
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; echo $n
4
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; n=n^2
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; echo $n
6
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; n=n**2
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; echo $n
36
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; n='n - 4'
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; echo $n
32
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; n=n/4
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; echo $n
8
-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[29908 0] ; o
      
倒是相当方便