I have a file which looks like this: 

```
30901 foo1 bar1 89
30902 foo2 bar2 51
30903 foo3 bar3 101
30903 foox bary 12
30903 fooz bara 23
30903 foob barc 62
30904 fooe barf 59
...
...

```

I want my output to have output like this: 

```
30901 89
30902 51
30903 49.5
... 

```

`49.5` being the average of fourth column, for all four duplicate entries for id: `30903` in column 1.

All I could do was to get number of unique entries using  

`cat <logfile> | awk '{print $1}' | uniq -c`  

to get the count of duplicate entries based on first column (id)