count no of words in a line

hi
i have a line
"abc,def,ghi,abc,def ,ghi,abc,def,ghi,abc,def ,ghi,abc,def,ghi,abc"
I want to print the no of words, words separated by comma

please help

Using awk u can do in this way :

awk -F"," '{print $NF}' Your_Filename

Use wc -w command to count the number of words. Use sed/awk to insert commas in between them

line="abc,def,ghi,abc,def ,ghi,abc,def,ghi,abc,def ,ghi,abc,def,ghi,abc"
oIFS=$IFS
IFS=,
set -f
set -- $line
set +f
IFS=$oIFS
echo $#