Set environment variables in Bourne shell (sh)

Posted October 11, 2003 by Quinn McHenry in Bourne shell

Last Updated on

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

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:


Multiple variables can be exported with one export command.


About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.

Leave a Reply