Reputation: 35
I have a file with more than 20 million records and want to sum 5th column for every unique value of 1st column, i have used the code below.
cat test.txt |awk 'BEGIN{FS="|"}{a[$1]+=$5;}END{for(i in a) print i"|"a[i];}'
maximum value of a[i] in the output is limited to 9999.
kindly help me...any solution??
Upvotes: 0
Views: 376
Reputation: 37424
$ cat > file
1||||a|NOTICE A LETTER IN FIFTH
1||||5
2||||57
2||||34535
3||||34535353
3||||1
1||||1
$ cat file|awk 'BEGIN{FS="|"}{a[$1]+=$5;}END{for(i in a) print i"|"a[i];}'
1: 6
2: 34592
3: 34535354
What do you get with my data above?
Upvotes: 1