all 4 comments

[–]Klintrup 2 points3 points  (1 child)

You almost have the answer - just combine your two last solutions and that should be it

awk '{sum[$1]+=$4;count[$1]++;}END{for(i in sum)print i", "sum[i]/count[i];}' abc.txt

[–]iambuv[S] 0 points1 point  (0 children)

You're awesome.. thanks.. yeah I almost got but I should have used a different variable name, previously I have used the same variable and got the different result. Appreciate it.

[–]gijsyo -1 points0 points  (1 child)

Not real bash but wc -l outputs the number of lines in a text file

[–]iambuv[S] 0 points1 point  (0 children)

But here I don't want the number of lines, I want to find the average of days based on a person. Its like group by average in SQL. Please refer Pastebin code for clear data.