How to set an environment variable in bash?

Posted on

How to set an environment variable in bash?

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.

Leave a Reply

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

Related Posts