How do I set an environment variable in Bash?

Environment variables are variables that contain values necessary to set up a shell environment. Environment variables persist in the shell’s child processes.

To set an environment variable in BASH, use the following command:

export VARIABLE=VALUE

Note: There is an equals sign between the variable name and the value.

If a variable has more than one value, separate them with a colon:

export VARIABLE_NAME=VALUE_1:VALUE_2

Variables that contain spaces are written under quotation marks:

export VARIABLE="VALUE 1"

Details

Article ID: 5207
Created
Tue 5/4/21 11:13 AM
Modified
Wed 7/19/23 12:20 PM