sum for unique value of particular column and print

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


sum for unique value of particular column and print



I have a file in the following format:


a|x|ahjkd|1

a|y|abd|2

b|x|tuj|3

b|gf|hui|4



I want the sum of column 4 for every unique value in column 1 and print all the lines along with the sum for corresponding column 1 i.e.



output should be like


a|x|ahjkd|1|3

a|y|abd|2|3

b|x|tuj|3|7

b|gf|hui|4|7





What have you tried so far?
– Ben Jones
Jul 19 at 19:34





Did you consider a particular programming / scripting language to achieve this?
– πάντα ῥεῖ
Jul 19 at 19:36







i want to do it using awk arrays
– user6677057
Jul 20 at 5:12









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Makefile test if variable is not empty