Name
export
Synopsis
export [variables] export [name=[value] …] export -p export [-fn] [name=[value] …]
Pass (export) the value of one or more shell variables, giving global meaning to the variables (which are local by default). For example, a variable defined in one shell script must be exported if its value is used in other programs called by the script. If no variables are given, export lists the variables exported by the current shell. The second form is the POSIX version, which is similar to the first form, except that you can set a variable name to a value before exporting it.
Options
-fNames refer to functions; the functions are exported in the environment.
-nRemove the named variables or functions from the environment.
-pPrint
exportbefore printing the names and values of exported variables. This allows saving a list of exported variables for rereading later.
Examples
In the original Bourne shell, you would type:
TERM=vt100 export TERM
In Bash, you could type this instead:
export TERM=vt100
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access