June 2017
Beginner
502 pages
11h 26m
English
This is like what we see at primary school; this operator allows us to add an integer to the value of the variable, as we can see in the following example:
#!/bin/bashecho "Hello user, please give me a number: " read user_input echo "And now another one, please: " read adding addition=$((user_input+adding)) echo "The number is: ${user_input:-99}"echo "The number added of ${adding} is: ${addition}"
Now time to invoke the script:
zarrelli:$ ./useraddition.sh Hello user, please give me a number: 120And now another one, please: 30The number is: 120The number added of 30 is: 150
As you have probably noted, we used a double parenthesis construct $(( )) to perform this arithmetic expansion and evaluation: in short, it is as we said, ...
Read now
Unlock full access