5.6 Adding up and substracting
With the incr command you can easily add up and substract numbers from strings.
The syntax of an incr command is incr <string> [+/-][number].
Here are a few simple examples to explain the command fast and easy:
#Add 1 up to the string test.
incr test
#Add 2 up to the string test.
incr test 2
#Add 3 up to the string test (the + sign is not required for addition).
incr test +3
#Substract 4 from the string test (the - sign is, logically, required for substraction).
incr test -4
With the incr command you can only add up and substract.
Dividing, multiplying and things like that have to be done
with the expr command, but that's something for later
on.
Note that the string you are inputting also has to be a valid
numeric number or the incr command will return an error.
|