>_ IzzyLab

Topic breakdown

Line-by-line file processing in bash is built on the while read loop idiom: on each iteration read puts the next line into a variable, while the file itself is fed to the loop via < redirection at the end of the loop body. Arithmetic in bash lives inside $(( ... )), where variables can be written even without $. A typical pattern is the accumulator: a variable set to zero before the loop, an addition on each iteration, and printing the total afterward.

What's checked

  1. total.txt has the sum of the numbers from numbers.txt
  2. sum.sh computes the sum from the file contents

What it looks like