shellwc

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?


Solution

  • Try this way:

    wc -l < file.txt