Well, it generally depends on the shell. For bash
, it marks the variable as "exportable" meaning that it will show up in the environment for any child processes you run.
Non-exported variables are only visible from the current process (the shell).
From the bash
man page:
export [-fn] [name[=word]] ...
export -p
The supplied names are marked for automatic export to the environment of subsequently executed commands.
If the
-f
option is given, the names refer to functions. If no names are given, or if the-p
option is supplied, a list of all names that are exported in this shell is printed.The
-n
option causes the export property to be removed from each name.If a variable name is followed by
=word
, the value of the variable is set toword
.
export
returns an exit status of 0 unless an invalid option is encountered, one of the names is not a valid shell variable name, or-f
is supplied with a name that is not a function.
You can also set variables as exportable with the typeset
command and automatically mark all future variable creations or modifications as such, with set -a
.