OSF DCE Administration Guide--Core Components

Using the DCE Control Program Command Language
24
dcecp> expr ($x-8)*2
32
dcecp> expr $x-(8*2)
8
dcecp> expr $x-8*2
8
dcecp>
Be careful using variables in expressions; variables like $x must be numeric strings like
24, not nonnumeric strings like 4*6.
The DCE control program normally treats numbers as decimal integers, but can read
numbers in octal and hexadecimal formats too. Precede a number with 0 (zero) for octal
interpretation, as in 0477. Precede a number with 0x for hexadecimal interpretation, as in
0x9FF. You can also represent numbers in floating-point format by using any of the
forms specified by the ANSI C standard (with the exception of the f, F, l, and L suffixes).
The DCE control program also supports numerous mathematical functions in expressions
such as cos, exp, log, tan, sin, and others, by invoking the C math library functions of the
same name.
Here’s a partial list of operators you can use with the expr command. The list order also
denotes precedence. This means, for instance, that expr multiplies before adding (2+2*4
equals 10).
- unary minus
~ bitwise NOT
! logical NOT
* multiply
/ divide
% remainder
+ add
- subtract
<< left shift
>> right shift
< Boolean less than
<= Boolean less than or equal
> Boolean greater than
>= Boolean greater than or equal
== Boolean equal
!= not equal
& bitwise AND
^ bitwise exclusive OR
| bitwise OR
&& logical AND
|| logical OR
a?b:c if-then-else (as in C).
124243 Tandem Computers Incorporated 2 15