Assignment operators

Assignment operators allow you to assign values to variables in Shell Script. Here are some of the most common assignment operators in Shell Script:

“=” (simple assignment)
“+=” (additive assignment)
“-=” (subtractive assignment)
“*=” (multiplicative assignment)
“/=” (divisive assignment)
“%=” (module assignment)

Here is an example of how to use the “+=” assignment operator in Shell Script to add a value to an existing variable:

number=5
number=10
echo “The number is $number”

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”

Variables

Variables are used in Shell Script to store temporary or permanent data such as strings or numbers. They can be defined and used in a variety of ways in a shell script.

To define a variable in a shell script, simply assign a value to it. Here’s an example of how to define a variable called “name”:

name=”Yan”

To use the variable in a later command in the script, simply use the variable name with a dollar sign ($) before it. Here is an example of how to print the value of the variable “name” using the “echo” command:

echo “Hello, $name!”