Set environment variables in Bourne shell (sh)

Contributor Icon Contributed by qmchenry Date Icon October 11, 2003  
Tag Icon Tagged: Bourne shell


An environment variable must be set and exported with separate commands in the Bourne shell. To set the EDITOR variable to vi, use:

EDITOR=vi
export EDITOR

These commands can be placed in ~/.profile to be executed automatically at login, placed in a shell script, or executed manually. Exporting a variable makes it available to other shells spawned from the current shell as when running another command or shell script.

To add to an existing variable, such as path, use this format:

PATH=$PATH:/usr/local/bin
export PATH EDITOR

Multiple variables can be exported with one export command.

Previous recipe | Next recipe |
 

Viewing 1 Comment

 
close Reblog this comment
blog comments powered by Disqus