Contents
How do you calculate in Linux?
expr & echo : Linux command is used for very basic math calculation.
…
Simply type “bc” on your terminal to launch the bc command and use the following symbols for calculation:
- Plus : Addition.
- Minus : Subtraction.
- Forward Slash : Division.
- Asterisk: Used for Multiplication.
How do you perform a math operation in a shell script?
The following arithmetic operators are supported by Bourne Shell.
…
Unix / Linux – Shell Arithmetic Operators Example.
| Operator | Description | Example |
|---|---|---|
| % (Modulus) | Divides left hand operand by right hand operand and returns remainder | `expr $b % $a` will give 0 |
| = (Assignment) | Assigns right operand in left operand | a = $b would assign value of b into a |