10. Shell Scripting Tutorial for Beginners - Perform Arithmetic Operations

Published: 06 September 2017
on channel: MyShadowbook Programmer
95
3

The Arithmetic expression is a very important feature for performing number arithmetic operations in scripts.
By default, variables are treated as strings in bash scripts.
But parsing a string to numbers is very easy using double parentheses and external command such as expr.

Arithmetic operations in Bash Shell
Arithmetic operations can be done on integers using the following methods

$(( expression ))
echo "Addition = $(( number_1 + number_2 ))"

expr — evaluate the expression
we can also use expr command to perform Arithmetic operations on numbers.

echo "Addition = $(expr $number_1 + $number_2 )"


On this page of the site you can watch the video online 10. Shell Scripting Tutorial for Beginners - Perform Arithmetic Operations with a duration of hours minute second in good quality, which was uploaded by the user MyShadowbook Programmer 06 September 2017, share the link with friends and acquaintances, this video has already been watched 95 times on youtube and it was liked by 3 viewers. Enjoy your viewing!