Using awk to count number of records

 I want to count all the records in a table through awk but NR prints record nos of all records not the total count. I even tried:

NF==4,count++{print count}

But its not working properly How can I do it through awk?


Please show a sample of your file and what you want to do with it (show the desired output ) next time. Just guessing what you want,

awk 'NF==4{count++} END {print count}' file

No comments:

Post a Comment