HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)

k
ksh(1) ksh(1)
(""), parameter and command substitution occurs and
\ quotes the characters \, `, ", and $. $*
and
$@ have identical meanings 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 new-line 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.
-d file True if file exists and is a directory.
-f file True if file exists and is an ordinary file.
-g file True if file exists and is has its setgid bit set.
-h file True if file exists and is a a symbolic link.
-k file True if file exists and is has its sticky bit set.
-n string True if length of string is non-zero.
-o option True if option named option is on.
-p file True if file exists and is a fifo special file or a pipe.
-r file True if file exists and is readable by current process.
-s file True if file exists and has size greater than zero.
-t fildes True if file descriptor number fildes is open and associated with a terminal dev-
ice.
-u file True if file exists and is has its setuid bit set.
-w file True if file exists and is writable by current process.
-x file True if file exists and is executable by current process. If file exists and is a
directory, the current process has permission to search in the directory.
-z string True if length of string is zero.
-L file True if file exists and is a symbolic link.
-O file True if file exists and is owned by the effective user ID of this process.
-G file True if file exists and its group matches the effective group ID of this process.
-S file True if file exists and is a socket.
Section 1416 Hewlett-Packard Company 7 HP-UX 11i Version 1: September 2005