Sep 26, 2011
56 Views
0 0

Shell Arithmetic

Written by

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.

Article Categories:
Shell script

Leave a Comment

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