How to set an environment variable in bash?

How to set an environment variable in bash?

asked Oct 2, 2013 by anonymous

1 Answer

 
Best answer

The syntax in bash for setting an environment variable is as follows.

export VARIABLE=value

Note that there is no space among the variable, the equals sign ("=") and the value. If the value has spaces, the value should be put in quotes.

To check it:

echo $VARIABLE

To show all environment variables set, run env, set (bash build-in command) or printenv.

To make the variable settings effect for each bash shell, put the exporting command to your ~/.bashrc, the individual per-interactive-shell startup file.

answered Oct 2, 2013 by anonymous

Please log in or register to answer this question.

Related questions

1 answer
asked May 23, 2017 by dtivl (2,500 points)
1 answer
asked Oct 2, 2013 by anonymous
1 answer
asked May 23, 2017 by dtivl (2,500 points)
1 answer
asked May 23, 2017 by dtivl (2,500 points)
1 answer
Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...