How to export variables in shell scripting

How to export variables in shell scripting

In this tutorial I will show you, how to export 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

Was this Tutorial helpful? Help others share on Facebook, Twitter, and Google Plus!

 
Enjoyed this video?
How to export variables in shell scripting
"No Thanks. Please Close This Box!"