In this article, we will see the different options available in performing arithmetic operations in UNIX . These will come handy while working at the command prompt or for writing scripts. For the sake of simplicity,we will take the example of adding two numbers.
1. The first example makes use of the expr command. All the other arithmetic operators(-,/,%) can be used in the same way except for *(multiplication).
$ x=3 $ y=4 $ expr $x + $y 7
To multiply the numbers, precede the * with a \. This is done in order to prevent the shell from interpreting the * as a wild card.