Take the 2-minute tour ×

I want to add values of unique column using bash command.

Input file:

Hello 3
World 5
Hello 3

Output file:

Hello 6
World 5
share|improve this question
There are approximately half a million questions on this site that do this. Did you try searching? –  devnull Apr 14 at 17:01

1 Answer 1

awk '{arr[$1]+=$2} END{for (i in arr) print i,arr[i]}' input.txt
share|improve this answer

Your Answer


