awk 'END{print NR}' file.txt

Category: Text Processing

awk 'END{print NR}' file.txt

Print the total number of lines in a file

NR at the END block holds the total number of lines processed — a way to count lines using awk.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.