10. Shell Scripting Tutorial for Beginners - Perform Arithmetic Operations

Publié le: 06 septembre 2017
sur la chaîne: 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 )"


Sur cette page du site, vous pouvez voir la vidéo en ligne 10. Shell Scripting Tutorial for Beginners - Perform Arithmetic Operations durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur MyShadowbook Programmer 06 septembre 2017, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 95 fois et il a aimé 3 téléspectateurs. Bon visionnage!