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

```
Could you please try following too in a single `awk`.

```
awk -F, '
!a[$1,$2,$3]++{
  b[$1,$2,$3]++
}
!f[$2]++{
  g[++count]=$2
}
END{
  for(i in b){
    split(i,array,",")
    c[array[2]]++
  }
  for(q=1;q<=count;q++){
    print c[g[q]],g[q]
  }
}' SUBSEP=","  Input_file

```

It will give the order of output same as Input\_file's 2nd field occurrence as follows.

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

```