title: Calculate the sum
body: <p>Let’s imagine we have a budget document: budget.txt</p>
  <p>The exercise is to calculate the sum column for every product in the month, also to calculate totals in the last row.
  You may try to do it in a shell.
  How shall it work?</p>
  <ul>
  <li>a program/script shall take a parameter with the filename (not to be hardcoded in the body)</li>
  <li>do the needful</li>
  <li>print output to a screen</li>
  <li>if there’s an error in the data file somewhere, the program/script shall print it on a screen and terminate.</li>
  </ul>
  <p>For the bash script, you may try with awk and bc commands.</p>
  <p><a href="https://i.stack.imgur.com/xzepZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xzepZ.jpg" alt="enter image description here" /></a></p>
  <p>I have created a shell script</p>
  <pre><code>#!/bin/bash
  echo -n &quot; Please write the file name:&quot; 
  read file 
  awk '{print $0}' $file
  </code></pre>