O'Reilly logo

Solaris™ 8 Advanced System Administrator's Guide, Third Edition by Janice Winsor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mathematical Operations

You can do mathematical operations only on integers (whole numbers) for all three shells. If you want to do more complicated arithmetic, use the awk or the bc command.

To perform mathematical operations in the Bourne shell, use the expr command. The expr command has the following syntax.

expr arguments
					

You must separate the mathematical operators (shown in Table 98) and the operand with white space.

Table 98. Mathematical Operators
Operator Description
+ Addition.
- Subtraction.
* Multiplication.
/ Division.
% Remainder (modulus).

The multiplication, division, and remainder operators have higher precedence than do the addition or subtraction operators. Use parentheses for grouping.

Bourne Shell Mathematical Operations ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required