HP-UX Reference (11i v3 07/02) - 1 User Commands N-Z (vol 2)
s
sh-posix(1) sh-posix(1)
history=’fc -l’
integer=’typeset -i’
local=typeset
nohup=’nohup ’
r=’fc -e -’
stop=’kill -STOP’
suspend=’kill -STOP $$’
type=’whence -v’
Tilde Substitution
After alias substitution is performed, each word is checked to see if it begins with an unquoted tilde (
˜). If
it does, the word up to a
/
is checked to see if it matches a user name in the /etc/passwd file. If a
match is found, the
˜ and the matched login name are replaced by the login directory of the matched user.
If no match is found, the original text is left unchanged. A
˜ alone or before a / is replaced by the value of
the
HOME parameter. A ˜ followed by a
+ or - is replaced by the value of the parameter PWD and
OLDPWD, respectively. In addition, tilde substitution is attempted when the value of a parameter assign-
ment begins with a ˜.
Command Substitution
The standard output from a command enclosed in parenthesis preceded by a dollar sign ($(...
)) or a pair of
grave accents (
‘...‘) can be used as part or all of a word; trailing newlines are removed. In the second
(archaic) form, the string between the accents is processed for special quoting characters before the com-
mand is executed. See the Quoting subsection. The command substitution $(cat file) can be
replaced by the equivalent but faster $(<file). Command substitution of most special commands that
do not perform input/output redirection are carried out without creating a separate process.
An arithmetic expression enclosed in double parenthesis preceded by a dollar sign ($((...))) is replaced by
the value of the arithmetic expression within the double parenthesis. See the Arithmetic Evaluation sub-
section for a description of arithmetic expressions.
Parameter Substitution
A parameter is an identifier, one or more decimal digits, or one of the characters
!, #, $, *, -, ?, @, and
_.Anamed parameter (a parameter denoted by an identifier) has a value and zero or more attributes.
Named parameters can be assigned values and attributes with the typeset special command. Exported
parameters pass values and attributes to the environment.
The shell supports a limited one-dimensional array facility. An element of an array parameter is refer-
enced by a subscript. A subscript is denoted by a [, followed by an arithmetic expression, followed by a
].
See the Arithmetic Evaluation subsection. To assign values to an array, use
set -A
name value .... The
value of all subscripts must be in the range of
0 through 1023. Arrays need not be declared. Any refer-
ence to a named parameter with a valid subscript is legal and an array is created if necessary. Referencing
an array parameter without a subscript is equivalent to referencing the first element.
If the -i integer attribute is set for name, the value is subject to arithmetic evaluation.
Positional parameters, parameters denoted by a number, can be assigned values with the
set special com-
mand. Parameter
0 is set from argument zero when the shell is invoked.
Use the prefix character $ to specify the value of a parameter for substitution.
$parameter
${parameter}
${
parameter[subscript]}
Substitute the value of the parameter, if any. Braces are required when parameter is fol-
lowed by a letter, digit, or underscore that should not be interpreted as part of its name or
when a named parameter is subscripted. If parameter is one or more digits, it is a posi-
tional parameter. A positional parameter of more than one digit must be enclosed in
braces. The shell reads all the characters from ${ to the matching } as part of the same
word, even if it contains braces or metacharacters.
If parameter is * or @, all the positional parameters, starting with 1, are substituted
(separated by a field separator character). See the Quoting subsection.
If an array parameter with subscript * or @ is used, the value for each element is substi-
tuted (separated by a field separator character).
254 Hewlett-Packard Company − 12 − HP-UX 11i Version 3: February 2007