z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Understanding shell variables

z/OS UNIX System Services User's Guide
SA23-2279-00

You can display the shell's variables and their values by entering this command:
set 
or
set -r
set -r displays readonly shell variables.

You may see many variables that you don't recognize. These are built-in, or predefined, variables that are set up with default values when you start the shell.

You can customize the built-in variables by setting their value in your .tcshrc file.

Only the shell variables that are defined in the .tcshrc file are available to shell scripts and commands invoked from the shell. Environment variables are inherited by subshells, and can be displayed by entering either of these commands:
setenv
printenv
 
You can display the value of a single variable with the echo command or the printenv command. For example, either of these commands
echo $HOME
  
printenv $HOME
displays the current value of the HOME variable.

In general, echo displays the current values of all its arguments, after any shell processing has taken place. The shell first expands the wildcard character *.

Example: Consider:
echo *.doc

Result: This produces the names of every file in the working directory that has the suffix .doc. So the output of echo is a list of all such files. And if there are no file names ending in .doc, the command output is just *.doc.

For more information about shell variables,

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014