I would like to type in two numbers and get the sum of all integers between those two numbers, inclusive.For example:./sum1 2 5should yieldsum: 14because 2+3+4+5 = 14Here's what I have so far:read num1 num2for (( i=$num1; i<=$num2; i++))donow how to do what i wantdoneecho The Sum of your two number and the numbers inbetween is:$iI guess I need another variable in there to somehow be added to, but I can't seem to find a good solution.
Sum of all Integers between two numbers
shell script;variable
Look for arithmetic evaluation in your shell documentation. For example in BASH it could be:n=0for (( i = $num1; i <= $num2; i++)); do    (( n += i ))doneecho $nGenerally, if you intend to use this often, you want to make it a function rather than a standalone script. It might be more appropriate to use (( n = n + i )) since the shortened += operator may not available in some shells that offer arithmetic evaluation.