Categories
Shell script

Shell Arithmetic

used to perform arithmetic operations in shell scripts.

Synatax: $ expr  op1 operator  op2

eg:

$ expr 1 + 3
$ expr 2 – 1
$ expr 10 / 2
$ expr 20 % 3
$ expr 10 * 3
$ echo `expr 6 + 3`

in the last one we used back quote (` the one below the tilde symbol in standard keyboards).

if we use the back quote the last eg’s output may differ.

Leave a Reply

Your email address will not be published. Required fields are marked *