Shell Variables

A Shell Variable is a variable part of a shell, of course. It also acts like a variable in shell scripts.

To refine this: A shell is a program that interprets commands using calls to other programs and a kernel program (hence the name shell). Many shells have statements that assign a value to a name, and allow this assigned value to be changed. The assignments (bindings) are stored as part of the shell program's data.

Notice that this means that when the shell program terminates or exits all its variables vanish with it. The shell encapsulates them.

Some shell variables are *exported* to the Environment Variables that are inherited by sub-processes. These variables and values are effectively pre-initialized for newly executed programs (by their parent processes or by the previous program that inhabited a given process space).

In many shell programs the command line arguments or parameters are numbered shell variable. There are always other special variable that are given values or supply data for multifarious purposes: TZ might indicate time zone and HZ the clock rate and $? an error number, and so on.

Syntactically, and in opposition to most programming languages, there is a special notation for the value of a shell variable. An explicit de-reference symbol. In UNIX shells this is the Dollar Sign.

-- DickBotting


EditText of this page (last edited March 4, 2005) or FindPage with title or text search