Shell have variables like variables used in other programming languages. Some shell variables are HOME( our login directory), PATH(list of directories to search for commands). Strings such as $1 are called positional parameters. Except positional parameters, shell variables can be accessed, modified and created.
We can modify PATH as
There should not be any space around ‘=’ sign.
We can list the shell variables and its value currently in our system using set command. We can also display individual values using a ‘$’ symbol.
eg: echo $PATH
When we are creating or modifying the value of a shell variable, the value is only associated with that shell. It cannot be used in any of the sub-shells.
To use the value of a shell variable in sub-shells- we have to use the ‘export’ command.
Now the value of x in the sub-shells is also ‘hai’.