user3753693 user3753693 - 1 month ago 7
Bash Question

CSV find blank value in third column KSH

Hi my data set is simple as show below

4,a,1.5
t,6,,
6,t,h


I am trying to use awk or grep to count the rows in which there is a blank in the third colmn. In this case it would be 1 since only the middle one has a blank in the column so far what i have tried is below. The login is trying to use awk to search for a blank string then count it the same with grep find where there is a blank in the third column then count it.

COUNT=$('awk '' $DATAFILE | wc -l')
COUNT=$('grep -e '.*,.*,,' $DATAFILE' | wc -l)

Answer
awk -F, '$3==""{c++} END{print c+0}' file