Entering edit mode
2.5 years ago
genomes_and_MGEs
▴
10
Hi everyone,
I have a text file that looks like this
A 30
A 25
B 40
B 50
C 5
D 2
...
My goal is to count and sum all values on column 2, according to the condition in column 1. For example, A=55, B=90, C=5, D=2, etc. I've try using grep and wc, but I'm missing something here:
grep -o 'A\|B\|C\|D\' file | awk '{print $2}' | wc
Can you please help me out? Thanks!
how is it related to bioinformatics ?? (btw you want
datamash groupby 1 sum 2
)What a great little tool datamash is, by the way.