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 
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 .profile. Only the variables IFS, PS1, and PS2 support double-byte characters for the values.

Only the shell variables that are exported are available to shell scripts and commands invoked from the shell. Environment variables are a subset of shell variables that have been exported.

You can display the environment variables and their values by entering either of these commands:
env
printenv
 
You can display the value of a single variable with the echo command, the print command, or the printenv command. For example, any of these commands
echo $HOME

print $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. For example, consider:
echo *.doc
The shell first expands the wildcard character *. 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