+2 votes
in Operating Systems by (3.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

0 votes
by (14.8k points)

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
 

...