January 2001
Intermediate to advanced
480 pages
7h 22m
English
Integer arithmetic can be done with the let command and arithmetic expressions. The format for the let command is:
let "arithmetic-expression"
where arithmetic-expressions can contain constants, operators, and Korn shell variables. Double quotes are used with arithmetic expressions that contain white space or operators that have special meaning to the Korn shell. For example, variable X can be set to the sum of 1+1 like this:
$ let "X=1 + 1" $ print $X 2
then incremented:
$ let "X=X + 1" $ print $X 3
Notice that in arithmetic expressions, regular variables can be referenced by name only, and do not have to be preceded by $ for substitution to be performed. Both
$ let "X=X + 1"
and
$ let "X=$X + 1"
are equivalent. The ...
Read now
Unlock full access