Shell variables related to Creation, Inspection, Modification , lists

Creating a Variable

Points to Note:

myvar="value string"

Exporting a Variable

export myvar="value string"

or

myvar="value string"
export myvar

Using Variable Values

echo $myvar  # $ sign is important
echo ${myvar} #Good method to use variable values
echo "${myvar}_something"

Removing a Variable

unset myvar    #removes the variable myvar
myvar=   #Same effect as above line

Test is a Variable is set

[[ -v myvar ]];
echo $?
# If myvar is unset, returns 1 i.e, myvar is not set.
# Returns 0 if myvar is set.
#used to check if variable is set

Return codes:

0 : success