Logged in as: Guest | Login/Register
 

Working with BASH environment variables (simple commands for beginners)

Tutorials > Operating Systems > Linux > Tips And Tricks > Working with BASH environment variables (simple commands for beginners)

Discuss this tutorial here | Search www.geeksww.com for more tutorials here

You'll learn the following in this tutorial.

I have tried instructions below on Ubuntu Server but should work for all distributions running the BASH shell.

Display names and values of all environment variables

env

Assign value to an environment variable

TESTVAR=value

Example:

TESTVAR=/usr/local/sbin:/usr/local/bin

Command above assigns the value "/usr/local/sbin:/usr/local/bin" to the TESTVAR variable.

Print value of a particular environment variable

echo $<variable name>

Example:

echo $TESTVAR

Command above prints the value of BASH's TESTVAR variable.

Append value to an existing environment variable:

<variable name>=$<variable name>:<new value>

Example:

TESTVAR=$TESTVAR:/bin

Command above appends "/bin" to the value of BASH's TESTVAR variable.

Make the variable globally accessible:

export <variable name>

Example:

export TESTVAR

Delete an environment variable:

unset <variable name>

Example:

unset TESTVAR


 
Discuss this tutorial here | Search www.geeksww.com for more tutorials here
 

Similar Tutorials:

 

Support Geeks Worldwide:

Link to us:

You can support us by putting a link to our website on your blog or website (code is below).

<a href="http://www.geeksww.com/">
Geeks Worldwide - Tutorials about Software Installation,
Configuration, Administration, Monitoring, Tools, Tips &
Tricks
</a>

OR a simple one.

<a href="http://www.geeksww.com/">
Geeks Worldwide - IT related Tutorials
</a>

Feedbacks:

We appreciate feedbacks and suggestions about our tutorials and Geeks Worldwide from readers. Please contact us using the form here and let us know what you think about the tutorial and the website in general.

Bookmark Us:

We are working on new features for the website, please keep visiting or bookmark us using your favourite bookmarking service.

Subscribe to RSS:

You can subscribe to our RSS feed here.

 
Creative Commons License