Bash /
ArithmeticBash is a language where string concatenation takes priority over arithmetic. Specifically, the result of Integer ArithmeticIn order to tell Bash that you want to actually do arithmetic, you need to surround the statement with double parentheses. x=2+2 echo $x -> 2+2 ((x=2+2)) echo $x -> 4 x=$x+8 echo $x -> 4+8 ((x=$x+3)) echo $x -> 15 Notice that, in the last statement, the original value of This method of doing arithmetic meets its limits very fast, however, as it is strictly integer based. The formulas cannot contain decimal points, and the result of every operation will be rounded down. For example:((x=3/2)) echo $x -> 1 ((x=2*3/2)) echo $x -> 3 ((x=3/2*2)) echo $x -> 2 where in the first formula Floating Point Arithmetic |