Variable Substitution
ksh93 provides structured
variables, such as pos.x
and
pos.y
. To create either one,
pos
must already exist, and
braces must be used to retrieve their values. Names beginning with
.sh
are reserved for use by
ksh.
No spaces should be used in the following expressions. The
colon (:
) is optional; if it’s
included, var must be nonnull as well as
set.
|
Set each variable var to a value. |
|
Use value of var; braces are optional if var is separated from the following text. They are required for array variables, and in ksh93 if a variable name contains periods. |
|
Use var if set; otherwise, use value. |
|
Use var if set; otherwise, use value and assign value to var. |
|
Use var if set; otherwise, print value and exit (if not interactive). If value isn’t supplied, print the phrase “parameter null or not set.” |
|
Use value if var is set; otherwise, use nothing. |
|
Use the length of var. |
|
Use the number of positional parameters. |
|
Same. |
|
Use value of var after removing pattern from the left. Remove the shortest matching piece. |
|
Same as |
|
Use value of var after removing pattern from the right. Remove the shortest matching piece. |
|
Same as |
In ksh93 and Bash:
|
Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.