Exporting variables in shell scripting

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

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

Tagged with: , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!