A variable in shell script is it is the means of referencing a numeric or character value. And unlike formal programming languages, a shell script does not require to declare the data type of the variables at the time of assigning the data to the variable. To access the value of a variables they should be prefixed with dollar($) sign.
Set a Variable:
The shell enables to set and unset the variables.
Syntax:
name=value
Example:
Name=Webnoid
This type of variables are called scalar variables, that is it can hold only one value at a time.
Accessing a Variable:
To access a variable, its name should be prefixed with a dollar($) sign.
Example: echo $Name
In the above example it will prints the data which is stored in the variable and gets an output “Webnoid”.
In order to store multiple words or multiple lines in a variable you need to use either single quote or double quotes.
Example:
Name =”Webnoid Schools”
OR
Name=’Webnoid Schools’
In above example while defining a name it can be given quotes if there are any spaces or special characters.