DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Programming with the SCO OpenServer system shell

Named variables

Another form of variable that you can use in a shell program is a named variable. You assign values to named variables yourself. The format for assigning a value to a named variable is:

   named_variable=value
Notice that there are no spaces on either side of the equals (=) sign.

In the following example, var1 is a named variable, and myname is the value or character string assigned to that variable:

   var1=myname
A ``$'' is used in front of a variable name in a shell program to reference the value of that variable. Using the example above, the reference $var1 tells the shell to substitute the value myname (assigned to var1), for any occurrence of the character string $var1.

The first character of a variable name must be a letter or an underscore. The rest of the name can consist of letters, underscores, and digits. Like shell program filenames, variable names should not be shell command names. Also, the shell reserves some variable names that you should not use for your variables. The following list provides brief descriptions of some of the most important of these reserved shell variable names.

Many of these variables are explained in ``Modifying your login environment''.

You can see the value of these variables in your shell in two ways. First, you can type

   echo $variable_name
The system outputs the value of variable_name. Second, you can use the env(C) command to print out the value of all defined variables in the shell. To do this, type env on a line by itself; the system outputs a list of the variable names and values.
Next topic: Assigning a value to a variable
Previous topic: Special parameters

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005