Can you please guide me, on how to group and aggregate the below value using a shell script (using awk
) or guide me on which is the best option?
Input textfile:
900|1000|currentaccount|usd|66.66|gbp|51.92|creditleg|121|888|999
900|1000|currentaccount|usd|77.66|gbp|71.92|creditleg|121|888|999
900|1000|currentaccount|usd|85.66|gbp|65.92|creditleg|121|888|999
900|1000|currentaccount|usd|66.66|gbp|51.92|creditleg|121|888|999
900|1000|currentaccount|usd|6.66|gbp|1.92|creditleg|121|888|999
My output should be as follows:
900|1000|currentaccount|usd|133.32|gbp|103.84|creditleg|121|888|999
900|1000|currentaccount|usd|77.66|gbp|71.92|creditleg|121|888|999
900|1000|currentaccount|usd|85.66|gbp|65.92|creditleg|121|888|999
900|1000|currentaccount|usd|6.66|gbp|1.92|creditleg|121|888|999
It aggregated and group the 1 and 4 because both are same vale, if any difference it should not aggregate.
Kindly guide thanks in advance.
133.32
as its 5th field and103.84
as its 7th field? Should that be added to the resulting entry? If you are summing currencies, isn't there a danger that the amount in Pound Sterling or US Dollars potentially are rounded wrongly?