The export
command in the Debian Almquist Shell (dash) is used to set environment variables that can be accessed by child processes. When a variable is exported, it becomes part of the environment for any subsequently executed commands.
The basic syntax of the export
command is as follows:
export [options] [arguments]
-n
: Unsets the export attribute for the specified variable, making it no longer available to child processes.-p
: Displays all exported variables and their values.To export a variable named MY_VAR
with the value Hello World
, you can use:
MY_VAR="Hello World"
export MY_VAR
You can export multiple variables in a single command:
export VAR1="Value1" VAR2="Value2"
To unset the export attribute of a variable, use the -n
option:
export -n MY_VAR
To display all currently exported variables, use the -p
option:
export -p
export
before running scripts that rely on specific environment variables to ensure they are available..bashrc
or .profile
.