Set an environment variable in Korn shell (ksh)


An environment variable can be set and exported in the Korn shell with a single command. To set the EDITOR variable to vi, use:

export EDITOR=vi

This command 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:

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

 

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.

4 Responses to “Set an environment variable in Korn shell (ksh)”

  1. February 11, 2009 at 11:23 am, mikolaj said:

    20% text and 80% adds. The level of “tech recipe” is far too basic.

    Reply

  2. March 02, 2009 at 12:36 pm, pratap said:

    how to remove the a perticular path from PATH env variable?

    Reply

  3. September 17, 2010 at 1:17 pm, eva said:

    Fantastic! Your info is so good! now i’l never have to RTFM anymore. I have you, you are my friend for life!

    Reply

  4. April 13, 2012 at 6:18 am, Diksha said:

    Hello,
    How to assign the multiple env to the single variable…

    Reply

Leave a Reply