background img
banner
Sep 26, 2011
220 Views
0 0

Shell Arithmetic

Written by
banner

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
banner

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.