Hey guys so i got this dummy data: 

```
115,IROM,1
125,FOLCOM,1
135,SE,1
111,ATLUZ,1
121,ATLUZ,2
121,ATLUZ,2
142,ATLUZ,2
142,ATLUZ,2
144,BLIZZARC,1
166,STEAD,3
166,STEAD,3
166,STEAD,3
168,BANDOI,1
179,FOX,1
199,C4,2
199,C4,2

```

Desired output:

```
IROM,1
FOLCOM,1
SE,1
ATLUZ,3
BLIZZARC,1
STEAD,1
BANDOI,1
FOX,1
C4,1

```

which comes from counting the distinct game id (the 115,125,etc). so for example the

```
111,ATLUZ,1
121,ATLUZ,2
121,ATLUZ,2
142,ATLUZ,2
142,ATLUZ,2

```

Will be

```
ATLUZ,3 

```

Since it have 3 distinct game id

I tried using 

```
cut -d',' -f 2 game.csv|uniq -c

```

Where i got the following output

```
  1 IROM
  1 FOLCOM
  1 SE
  5 ATLUZ
  1 BLIZZARC COMP
  3 STEAD
  1 BANDOI
  1 FOX
  2 C4

```

How do i fix this ? using bash ?
['https://Stackoverflow.com/questions/51943181', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3646742/']
Before executing the `cut` command, do a `uniq`. This will remove the redundant lines and then you follow your command, i.e. apply `cut` to extract `2` field and do `uniq -c` to count character

```
uniq game.csv | cut -d',' -f 2 | uniq -c

```
This also does the trick. The only thing is that your output is not sorted.

```
awk 'BEGIN{ FS = OFS = "," }{ a[$2 FS $1] }END{ for ( i in a ){ split(i, b, "," ); c[b[1]]++ } for ( i in c ) print i, c[i] }' yourfile

```

Output: 

```
BANDOI,1
C4,1
STEAD,1
BLIZZARC,1
FOLCOM,1
ATLUZ,3
SE,1
IROM,1
FOX,1

```