camma challenge (in ksh)

Hi Gurus,

I am a starter in ksh scripting

I have a requirment where i need to ucertain that each line contain only 5 occurances of "," (comma) in a CSV file ; I don't want to use perl,is it possible in ksh;; Kindly help

I am going to read CSV file and ; redirect all those lines which are not having 5 cammas to a bad record file.

example

good record with five ','

a,b,c,d,f,g
,,b,c,,
,b,,c,d,

bad record > 5 , or ,<5

a,b,c
a,b,c,d,e,f,g,h,

Hope some one will be able to help me.Thanks in advance

Regard
Ama

awk '{l=$0;}gsub(",","") != 5{print l}' "file"

ghostdog74
thanks "ghostdog74" you saved my life..

Another way, always with awk :

if awk -F, 'NF != 6 { exit 1 }' file
then
   echo "Valid File"
else
   echo "Invalid File"
fi

Jean-Pierre.