Hands-on task
This task is step 14 of the course “Bash scripts: from a loop to a robust script”
Sum of numbers from a file
/root/numbers.txt has one integer per line. Write /root/sum.sh that computes their sum and prints it. Run it and save the result to /root/total.txt.
What you'll practise:
- while read
- bash arithmetic
- $(( ))
- input redirection
- accumulating a sum