Skip to content
Advertisement

How to compute Cumulative values in Shell?

I would like to compute cumulative values from the below data file and writing them into columns after inserting a serial number.

JavaScript

Where ifile.txt has 3 rows and 9 columns in this example. Desire output:

JavaScript

Here first column is used for the serial number. So what I did is: I first converted into columns using

JavaScript

Then I use awk

JavaScript

I can’t proceed for the next step i.e. to insert a column of serial number. Also I can’t make it for arbitrary columns and rows.

Advertisement

Answer

for column of serial number

JavaScript

and for complete solution of your logic

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement