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

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

Liked it? Take a second to support Geekster on Patreon!
Tagged with: , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

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


Support LinuxG via Patreon
Support LinuxG.net on Patreon!


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