How to get the record count of columns matching with particular value using awk command in linux

 


I have to display the record count of columns matching "CD" from my input csv file. Value CD is appearing in second column in my file input.csv.

I am trying with below command but it is not working as expected.

awk -F',' '$2=/CD/ { count++ } END { print count }' input.csv

My input data:

1234,CD,xyz,abcd
01235,AB,kasdjk,aaaaa,fff
898,CD,laklksas,lsjdjdj,lkjsaj
111,CD,lkakskaks,jjjjjj
3455,00,ksajkjsa,kkkkk
59995,99,asllsal,99898,00,kkk,99
99,00,lkjjjsa,00,99,hhhh

Expected output:

3 if i check the count of "CD"
2 if i check the count of "00"