export Command: Tutorial & Examples
Set the value of an environment variable
The export
command is a Unix utility that sets an environment variable for the current shell and its child processes. Environment variables are values that can be passed to the
shell and its commands, and they are used to store information such as the directories that should be searched for executables (PATH
), the current user's home directory (HOME
),
and the current terminal type (TERM
).
To use the export
command, you can specify the name of the environment variable you want to set and the value you want to assign to it. For example:
export MYVAR=value
This will set the environment variable MYVAR
to the value value
. You can then use the echo
command to display the value of the environment variable:
echo $MYVAR
This will output the value value
.
The export
command is often used in shell scripts to set environment variables that will be used by the script and its child processes. It is a useful tool for defining variables
that can be used to customize the behavior of the shell and its commands.