How to only get the number of lines of a file

bash, linux

Solution

Try this

wc -l < sample.txt

`wc` doesn't print out the filename if it reads the file through standard input. The `<` feeds the file via standard input.

Problem

How do I get the number of lines of a file in linux? I only want the number of lines, not the filename. I want to do it in a single command, without grep or another utility. ``` wc -l sample.txt ``` Output ``` 5 sample.txt ``` Desired Output ``` 5 ```

Original source