I have a .txt file:
a 10
b 13
a 2
b 5
c 1
Where the first column is for the identifiers, and the second one is for the values.
If I wanted to go over the file using awk and sum up the numbers in the second column for each item in the first column, then replace it with * before printing so the output is as below, how would I go about that?
a : **
b : **
c : *
So that the number of stars is equal to the number of digits in the number (12 -> **, 18 -> **, 1 -> *)
awk '{gsub("12", "**"); print}' test.txt
I've tried this, but of course it's not the right solution. Open for any advice.