The export
command is used to set environment variables in a Bash shell, making them available to child processes.
The export
command allows you to create environment variables or mark existing shell variables for export to child processes. This is essential for passing configuration settings or other data to scripts and programs that are executed from the shell.
The basic syntax of the export
command is as follows:
export [options] [arguments]
-n
: Unsets the export property for the specified variable, making it a regular shell variable.-p
: Displays all exported variables and their values.To create and export a new environment variable named MY_VAR
with the value Hello, World!
, use:
export MY_VAR="Hello, World!"
If you already have a variable and want to export it, you can do so like this:
MY_VAR="Hello, World!"
export MY_VAR
To unset the export property of a variable, use the -n
option:
export -n MY_VAR
To see all currently exported variables, you can use:
export -p
unset
to remove a variable entirely if it is no longer needed.