Arithmetic Operators
The following sections contain examples for each of the arithmetic operators available to the Korn shell. Table 6.1 lists all of the arithmetic operators available to the Korn shell in order of precedence.
–expression (Unary Minus)
Evaluates to the negative value of expression.
$ ((X=—7)) $ ((Y=—X + 2)) $ print — "$X $Y" —7 9
The print – command is used so that the negative sign is not interpreted as an argument.
!expression (Logical Negation)
The ! operator returns 0 (true) for expressions that do not evaluate to zero, or 1 (false) if they do.
$ X=0 $ ((X=!X)); print "$X" 1 $ ((X=!X)); print "$X" 0
∼expression (Bitwise Negation)
Evaluates to the bitwise negated value (one's complement) of expression. It returns a ...
Get Korn Shell: Unix and Linux Programming Manual, Third Edition, The 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.