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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

that if you just enter $d to refer to the dth positional parameter, d can only<br />

be a single digit; with brace brackets, number can be greater than 9.) Since<br />

braces mark the beginning and end of the name, you can have a letter or<br />

digit immediately following the expression.<br />

${variable[arithmetic expression]}<br />

Expands to the value of an element in an array named variable. The<br />

arithmetic expression gives the subscript of the array. (See “Arithmetic<br />

Substitution” on page 562.)<br />

${variable [*]}<br />

Expands to all the elements in the array variable, separated by the first<br />

character of the value of $IFS.<br />

${variable [@]$}<br />

When unquoted, is the same as ${ variable[*]} When quoted as “${variable<br />

[@]$} ,” it expands to all the elements in the array variable, with each<br />

element quoted individually.<br />

${#parameter}<br />

Expands to the number of characters in the value of the given parameter.<br />

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

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

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

${#variable [*]}<br />

Expands to the number of elements in the array named variable. Elements<br />

that do not have assigned values do not count. For example, if you only<br />

assign values to elements 0 and 4, the number of elements is 2. Elements 1<br />

through 3 do not count.<br />

${parameter:–word}<br />

Expands to the value of parameter if it is defined and has a nonempty<br />

value; otherwise, it expands word. This means that you can use word as a<br />

default value if the parameter isn’t defined.<br />

${parameter–word}<br />

Is similar to the preceding construct, except that the parameter is expanded<br />

if defined, even if the value is empty.<br />

${variable:=word}<br />

Expands word with parameter expansion and assigns the result to variable,<br />

provided that variable is not defined or has an empty value. The result is<br />

the expansion of variable, whether or not word was expanded.<br />

${variable=word}<br />

Is similar to the preceding construct, except that the variable must be<br />

undefined (it cannot just be null) for word to be expanded.<br />

${parameter:?word}<br />

Expands to the value of parameter provided that it is defined and<br />

non-empty. If parameter isn’t defined or is null, sh expands and displays<br />

word as a message. If word is empty, sh displays a default message. After<br />

a non-interactive shell has displayed a message, it ends.<br />

${parameter?word}<br />

Is similar to the preceding construct, except that sh displays word only if<br />

parameter is undefined.<br />

sh<br />

Chapter 2. Shell command descriptions 561

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

Saved successfully!

Ooh no, something went wrong!