Answer the question
In order to leave comments, you need to log in
How to add numbers from x to y in bash?
Good afternoon. According to the task, it is necessary to add the number from x to y that were entered by the user. And the only thing I thought of was to do the following.
#!/bin/bash
read -p "Type some number: " num
for((i=0;i<${#num};i++)); do ((sum+=${num:i:1})); done
echo "$sum
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question