simple awk question to count columns

hi all here is a very simple question.. i want to count the number of columns using awk..my file looks like this:

1,2
1,2
1,2
1,2
1,2
1,2
1,2 
1,2

i want to count number of columns and i so far i have:

awk 'BEGIN {IFS=","} END {print NF}' data  > data1

i am getting 1 as my result.. what am i missing here? thanks

ok i got it..

awk 'BEGIN {FS=","} ; END{print NF}' data  > data1

got confused with nawk..

awk 'BEGIN {FS=","} END {print NF}' datain  >dataout

I hope it works. At least in Linux it does.
Regards.

Edit: Upss, too late :slight_smile:

Warning: for some awk-s, the value of 'NF' is not visible in the 'END' block.

nawk -F',' '{print NF;exit}' data  > data1