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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With