Arithmetic operations are an essential requirement for every programming language. The Bash shell comes with a variety of methods for arithmetic operations.
The Bash shell environment can perform basic arithmetic operations using the commands
(( )), and
. The two utilities
bc are also very helpful in performing advanced operations.
A numeric value can be assigned as a regular variable assignment, which is stored as string. However, we use methods to manipulate as numbers.
#!/bin/bash no1=4; no2=5;
let command can be used to perform basic operations directly.
let, we use variable names without the
$ prefix, for example:
let result=no1+no2 echo $result