May 2013
Beginner to intermediate
384 pages
7h 40m
English
Arithmetic operations are an essential requirement for every programming language. In this recipe, we will explore various methods for performing arithmetic operations in shell.
The Bash shell environment can perform basic arithmetic operations using the commands let, (( )), and []. The two utilities expr and bc are also very helpful in performing advanced operations.
#!/bin/bash no1=4; no2=5;
let command can be used to perform basic operations directly. While using let, we use variable names without the $ prefix, for example:let result=no1+no2 echo $result ...
Read now
Unlock full access