The commands described below need to be entered while logged in to the Unix server. Normally you'll see a prompt ending with $ when the command interpreter (or shell) is ready for another command.
An 'environment variable' (also known as an 'export variable') is a name or identifier, used in your login shell, which may be used to refer to something else that would be too verbose to type out in full each time it is used. It is also a convenient way of controlling the way some programs run. SCRATCH is an example of an environment variable.
When used as part of a command they need to be preceded by a '$', hence '$SCRATCH'. They are called environment variables because they are used to modify the environment in which some programs run on the central system. They are also called export variables because they are exported into program environments. Unexported shell variables remain available only to the shell in which they are created.
For example, an ordinary shell variable can be created like this:
FOO="The fat cat sat on the mat"
But an export variable is created like this:
export FOO="The fat cat sat on the mat"
or by exporting a previously created ordinary shell variable:
export FOO
There are a number of standard environment variables which are used by a number of different programs. One is EDITOR and may be used to store the full pathname of your preferred text editor. Programs such as alpine can use this. Another is HOME, which refers to your home directory. You can also invent environment variables of your own if you wished to.
To get a list of all your environment/export variables and their values, give the command
export
by itself. The list may be quite long!
To find out the value of a given export variable - for example EDITOR - just type the command
print $EDITOR
(Note that you need to put a $ before the name in this context)
Please suggest an improvement
(login needed, link opens in new window)
Your views are welcome and will help other readers of this page.