DEV Community

Rahul Mahendru
Rahul Mahendru

Posted on

To Add a new header in second line of the existing file and 3 rd. column should be sum of the records

In source i am getting below data in csv format
Comp CAD Amount
2135 CAD 156.56
2135 CAD 171.33
2135 CAD 156.56
2135 CAD 156.56
2135 CAD 137.15

I need to add need header in Bottum of the old header

example
orignal header--->Comp CAD Amount
added_new header->Customer second_hader(with empty) sum(Amount)

Sum(amount) data will show like this

Comp code CAD Amount
Customer Invoice 778.16
2135 CAD 156.56
2135 CAD 171.33
2135 CAD 156.56
2135 CAD 156.56
2135 CAD 137.15

How I write the code in shell script and save the data in existing file

Top comments (0)