Exporting variables in shell scripting

The export command is mostly used when setting up a new PATH.

Watch Free Movies

You need to export a variable, in order to use it globally. By default, a variable can be used only local, unless it is exported.

$ x=/home/razvan
$ echo $x
/home/razvan

Start a new shell and display the value:

$ bash
$ echo $x
# you will get a new line as an output

Export the variable in order to use it globally:

$ export x=/home/razvan
$ bash
$ echo $x
/home/razvan

Scroll to Top