HP-UX Reference (11i v3 07/02) - 1 User Commands A-M (vol 1)
k
ksh(1) ksh(1)
the pattern, the word is left unchanged.
In addition to the notation described in regexp(5),
ksh recognizes composite patterns made up of one or
more pattern lists separated from each other with a
|. Composite patterns can be formed with one or more
of the following:
?(pattern-list) Optionally matches any one of the given patterns.
*(pattern-list) Matches zero or more occurrences of the given patterns.
+(pattern-list) Matches one or more occurrences of the given patterns.
@(pattern-list) Matches exactly one of the given patterns.
!(pattern-list) Matches anything, except one of the given patterns.
Quoting
Each of the metacharacters listed above (See Definitions above) has a special meaning to the shell and
causes termination of a word unless quoted. A character can be quoted (i.e., made to stand for itself) by
preceding it with a
\. The pair
\newline is ignored. All characters enclosed between a pair of single quote
marks (
’’), are quoted.
A single quote cannot appear within single quotes. Inside double quote marks ("..."), parameter and com-
mand substitution occurs and
\ quotes the characters \, ‘, ", and $.
$* and $@ have identical mean-
ings when not quoted or when used as a parameter assignment value or as a file name. However, when
used as a command argument,
"$*" is equivalent to "$1d$2d...", where d is the first character of the
IFS parameter, whereas "$@" is equivalent to "$1" "$2" ....
Inside back single quote (accent grave) marks (‘..‘), \ quotes the characters
\, ‘, and $.
If the back single quotes occur within double quotes,
\ also quotes the character ".
The special meaning of keywords or aliases can be removed by quoting any character of the keyword. The
recognition of function names or special command names listed below cannot be altered by quoting them.
Arithmetic Evaluation
The ability to perform integer arithmetic is provided with the special command
let. Evaluations are per-
formed using long arithmetic. Constants take the form [base#]n, where base is a decimal number between
two and thirty-six representing the arithmetic base and n is a number in that base. If base is omitted, base
10 is used.
An arithmetic expression uses the same syntax, precedence, and associativity of expression of the C
language. All the integral operators, other than
++, --, ?:, and ,
are supported. Variables can be refer-
enced by name within an arithmetic expression without using the parameter substitution syntax. When a
variable is referenced, its value is evaluated as an arithmetic expression.
An internal integer representation of a variable can be specified with the
-i option of the typeset spe-
cial command. Arithmetic evaluation is performed on the value of each assignment to a variable with the
-i attribute. If you do not specify an arithmetic base, the first assignment to the variable determines the
arithmetic base. This base is used when parameter substitution occurs.
Since many of the arithmetic operators require quoting, an alternative form of the let command is pro-
vided. For any command beginning with
((, all characters until the matching )) are treated as a quoted
expression. More precisely, ((...)) is equivalent to let " ...".
Prompting
When used interactively, the shell prompts with the value of PS1 before reading a command. If at any
time a newline is typed and further input is needed to complete a command, the secondary prompt (the
value of PS2) is issued.
Conditional Expressions.
A conditional expression is used with the [[ compound command to test attributes of files and to com-
pare strings. Word splitting and file name generation are not performed on the words between [[ and ]].
Each expression can be constructed from one or more of the following unary or binary expressions:
-a file True if file exists.
-b file True if file exists and is a block special file.
-c file True if file exists and is a character special file.
HP-UX 11i Version 3: February 2007 − 7 − Hewlett-Packard Company 495