Arithmetic in Bash
$ x=2
$ echo $x
2
$ (( x = x + 3 ))
$ echo $x
5
$ ((x=x+3))
$ echo $x
8
$ ((x+=1))
$ echo $x
9
$ ((x++))
$ echo $x
10
$ ((x*=2))
$ echo $x
20
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
$ x=2
$ echo $x
2
$ (( x = x + 3 ))
$ echo $x
5
$ ((x=x+3))
$ echo $x
8
$ ((x+=1))
$ echo $x
9
$ ((x++))
$ echo $x
10
$ ((x*=2))
$ echo $x
20