Count number of lines
Count number of lines in a text file:
$ awk '{print NR}' file.txt
This will give correct answer even if there is no
EOL
character at the last line. In contrast wc
-l file.txt
would give wrong answer (1 less) in that
case.