How to get “wc -l” to print just the number of lines without file name?

wc -l file.txt

outputs number of lines and file name.

I need just the number itself (not the file name).

I can do this

 wc -l file.txt | awk '{print $1}'

But maybe there is a better way?

10 Answers
10

Leave a Comment