Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 0,2,,,10
- 0,2,,,15
- 0,1,,,984
- 0,2,,,9
- 1,14,,,5
- 2,34
- 1,984
- 14,5
- awk -F, '{a[$2]+=$5};END{for(i in a)print i","a[i]}' <file
- datamash -t ',' -s -g 2 sum 5 <infile
- 1,984
- 14,5
- 2,34
- #!/usr/bin/env perl
- use strict;
- use warnings;
- my %things;
- while (<>) {
- my ( undef, $key, @rest ) = split(/,/);
- $things{$key} += pop(@rest);
- }
- foreach my $key ( sort { $a <=> $b } keys %things ) {
- print "$key = $things{$key}n";
- }
Add Comment
Please, Sign In to add comment