Shell Script to Group by Based on Multiple Fields in a file

Hi,

I want to know if there is any simple approach to SUM a field based on group by of different fields

for e.g.
file1.txt contains below data

20160622|XXX1||50.00||50.00|MONEY|Plan1|
20160622|XXX1||100.00||100.00|MONEY|Plan1|
20160623|XXX1||25.00||25.00|MONEY|Plan1|
20160622|XXX2|||||MONEY|Plan4|
20160622|XXX3||20.00||20.00|MONEY|Plan5|

Now i want to
group by based on COLUMN - 2,3,5,7,8
SUM the column 4,6
Get Max Date of Column 1

Output Expected :

20160623|XXX1||175.00||175.00|MONEY|Plan1|
20160622|XXX2|||||MONEY|Plan4|
20160622|XXX3||20.00||20.00|MONEY|Plan5|

Please help.

Is this a homework assignment?

What have you tried to solve this problem?

What operating system and shell are you using?

How did you arrive at the SUM of 50.00 + 100.00 + 25.00 being 275.00?

Moderator comments were removed during original forum migration.
1 Like