Exporting shell variables (export shell command)

A local shell variable is a variable known only to the shell that created it. If you start a new shell, the old shell's variables are unknown to it. If you want the new shells that you open to use the variables from an old shell, export the variables to make them global.

You can use the export command to make local variables global. To make your local shell variables global automatically, export them in your .profile file.
Note: Variables can be exported down to child shells but not exported up to parent shells.
See the following examples:
  • To make the local shell variable PATH global, type the following:
    export PATH
  • To list all your exported variables, type the following:
    export
    The system displays information similar to the following:
    DISPLAY=unix:0
    EDITOR=vi
    ENV=$HOME/.env
    HISTFILE=/u/denise/.history
    HISTSIZE=500
    HOME=/u/denise
    LANG=En_US
    LOGNAME=denise
    MAIL=/usr/mail/denise
    MAILCHECK=0
    MAILMSG=**YOU HAVE NEW MAIL. 
    USE THE mail COMMAND TO SEE YOUR MAILPATH=/usr/mail/denise?denise has mail !!!
    MAILRECORD=/u/denise/.Outmail
    PATH=/usr/ucb:/usr/lpp/X11/bin:/bin:/usr/bin:/etc:/u/denise:/u/denise/bin:/u/bin1
    PWD=/u/denise
    SHELL=/bin/ksh