+3 votes
in Operating Systems by (56.7k points)
I want to count the number of lines in my file using awk/gawk. What is the awk command to find the number of lines?

1 Answer

+1 vote
by (349k points)
selected by
 
Best answer

You can use one of the followings to count the number of lines in your file:

$ awk 'END{print FNR}' filename

$ awk 'END{print NR}' filename

$ awk 'BEGIN{i=0}{i++;}END{print i}' filename

$ awk '{i++;}END{print i}' filename
 


...