DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Configuring and working with the shells

Exporting variables to the environment

Variables stored in the environment are visible to you within the shell; but variables you set within your shell session are not accessible to other programs running in the environment until you make them so by explicitly exporting them.

To export a shell variable to the environment, use the export command. For example, in the Bourne and Korn shells:

   $ FOO=bar
   $ export FOO
In the Korn shell, the following alternative form exists:
   $ export FOO=bar
In the C shell:
   % setenv FOO bar
This will cause the variable FOO to be exported to any processes started from within the current shell.

You can export more than one variable at a time with the export command by listing a set of variable names to be exported. (There may already be an export command in your startup file. In this case, add the name of the additional variable to the end of the list of variables for export.) For example:

.
.
.
#
PATH=/bin:/usr/bin:/u/bin:/usr/local/bin:/local/bin:${HOME}/bin:
LOGNAME=charles
MAIL=${HOME}/.mailbox
.
.
.
export PATH LOGNAME ...
.
.
.

Next topic: A sample login script
Previous topic: Setting environment variables

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003