Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Calculating with variables z/OS UNIX System Services User's Guide SA23-2279-00 |
|
Suppose
you run the following commands either in a shell script or by typing
in one command after another:
The output of echo is 1+1, because
a normal variable assignment assigns a string to a variable.
Thus j gets the string 1+1.To evaluate an arithmetic expression, you
can enter:
This
command line assigns the value of an expression to the given variable.
For example:
Here j is assigned the value of the expression
and the echo command displays the value 2.You can also use let to change the value of a variable.
If you enter:
the let command changes the
value of i. The new value of i is the old value
plus 1.A let command can have any of the standard arithmetic
expressions:
assigns 11 to i, because the multiplication is done
first. You can use parentheses in the usual way to change the order
of operations. For example:
assigns 21 to i.
Note: let does not work with numbers that
have fractional parts. It works only with integers.
|
Copyright IBM Corporation 1990, 2014
|