Skip to content

Arithmetic operation in Bash

1:$(( ))

2:$[ ]

3:expr

C=`expr $A + $B`

4:bc命令

#!/bin/bash
x=1
y=2
echo $(( x + y ))
echo $[ $x + $y ]
echo `expr $x + $y`
let z=$x+$y
echo $z

bc <<< "scale=3; 11/15"

5:let

let C=$A+$B