Shell arithmetic



$ expr 2 + 3
5


declare variable using 
declare -i variable_name
(typeset -i obsolete way?)

Opeartors
+
-
*
/
% modulo
<< - left shift
>> - right shift
& | ^ ~  - bitwise and, or, not, one's complement


examples/script/math.sh
#!/bin/bash

declare -i a=2 
declare -i b=3
echo $a
echo $b

a=a+b
echo $a

echo '-----'

a=1
while (( a <= 10 ))
do
   echo $a
   a=$a+1
done

Arithmetic tests
&lt;=
&lt;
&gt;=
&gt;
==
!=
!
&amp;&amp;
||