June 2017
Beginner
502 pages
11h 26m
English
This operator adds a quantity to the value of the variable and assigns the outcome to the variable itself, but to clarify its use, let's rewrite one of the examples we've seen before:
#!/bin/bash echo "Hello user, please give me a number: " read user_input echo "And now another one, please: "
Adding
echo "The user_input variable value is: ${user_input}"echo "The adding variable value is: ${adding}"echo "${user_input} added of ${adding} is: $((user_input+=adding))"echo "And the user_input variable has now the value of ${user_input}"echo"But the adding variable has still the value of ${adding}"
And now, let's run it, as follows:
zarrelli:~$ ./userreassign.sh Hello user, please give me a number: 150And now another one, please: ...
Read now
Unlock full access