export - Set a variable for export

Format

  • export [ name [=value] ...]
  • export -p

Description

export marks each variable name so that the current shell makes it automatically available to the environment of all commands run from that shell. Exported variables are thus available in the environment to all subsequent commands. Several commands (for example, cd, date and vi) look at environment variables for configuration or option information.

Variable assignments of the form name=value assign value to name as well as marking name for export. The name can contain only the underscore and alphanumeric characters from the portable character set.

Calling export without arguments lists, with appropriate quoting, the names and values of all variables in the format Variable="value". If you reinput this format to another shell, variables are assigned appropriately but not exported. The –p option lists variables in a format suitable for reinput to the shell (see the description of the –p option).

Options

-p
Lists variables in a form that is suitable for reinput to the shell:
export name="value"

Usage notes

export is a special built-in shell command.

Localization

export uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_MESSAGES
  • NLSPATH

See Localization for more information.

Exit values

0
Successful completion.
1
Failure due to incorrect command-line argument.
2
Failure, usually due to incorrect an incorrect command-line argument, that results in a usage message.

Portability

POSIX.2, X/Open Portability Guide.

Assigning a value to name, and the behavior given for calling export with arguments are extensions of the POSIX standard.

Related information

cd, date, set, sh, typeset, vi