16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

sh<br />

Variables are named parameters.For details on naming and declaring variables, see<br />

“Variables” on page 567.<br />

The simplest way to use a parameter in a command line is to enter a dollar sign ($)<br />

followed by the name of the parameter. For example, if you enter the command:<br />

echo $x<br />

sh replaces $x with the value of the parameter x and then displays the results<br />

(because echo displays its arguments). Other ways to expand parameters are<br />

shown in the following paragraphs.<br />

The following parameters are built in to the shell:<br />

$1, $2, ... $9<br />

Expands to the d positional parameter (where d is the single digit following<br />

the $). If there is no such parameter, $d expands to a null string.<br />

$0 Expands to the name of the shell, the shell script, or a value assigned when<br />

you invoked the shell.<br />

$# Expands to the number of positional parameters.<br />

$@ Expands to the complete list of positional parameters. If $@ is quoted, the<br />

result is separate arguments, each quoted. This means that:<br />

"$@"<br />

is equivalent to:<br />

"$1" "$2" ...<br />

$* Expands to the complete list of positional parameters. If $* is quoted, the<br />

result is concatenated into a single argument, with parameters separated by<br />

the first character of the value of IFS (see “Variables” on page 567). For<br />

example, if the first character of IFS is a blank, then:<br />

"$*"<br />

is equivalent to:<br />

"$1 $2 ..."<br />

$– Expands to all options that are in effect from previous calls to the set<br />

command and from options on the sh command line.<br />

$? Expands to the exit status of the last command run.<br />

$$ Expands to the process ID of the shell. If running in a child shell<br />

environment (see “Shell Execution Environments” on page 567), it is the<br />

process ID of the parent shell. Otherwise, it is the process ID of the current<br />

shell.<br />

$! Expands to the process number of the last asynchronous command.<br />

These constructs are called parameters of the shell. They include the positional<br />

parameters, but are not restricted to the positional parameters.<br />

We have already mentioned that you can expand a parameter by putting a $ in front<br />

of the parameter name. More sophisticated ways to expand parameters are:<br />

${parameter}<br />

Expands any parameter.<br />

${number}<br />

Expands to the positional parameter with the given number. (Remember<br />

560 z/<strong>OS</strong> <strong>V1R9.0</strong> <strong>UNIX</strong> <strong>System</strong> <strong>Services</strong> <strong>Command</strong> Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!