Arithmetic operators

Arithmetic operators allow you to perform mathematical operations in Shell Script. Here are some of the most common arithmetic operators in Shell Script:

“+” (addition)
“-” (subtraction)
“*” (multiplication)
“/” (division)
“%” (modulo, which returns the remainder of a division)

Here is an example of how to use arithmetic operators in Shell Script to calculate the sum of two numbers:

number 1=5
number 2=10
sum=$((number1 + number2))
echo “The sum of $number1 and $number2 is $sum”

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *