I have a non-empty file (even a big one, 400Ko), that I can read with less.
But if I try to output the number of lines with wc -l /path/to/file it outputs 0.
How can it be possible?
You can verify for yourself that the file contains no newline/linefeed (ASCII 10) characters, which would result in wc -l reporting 0 lines.
First, count the characters in your file:
wc -c /path/to/file
You should get a non-zero value.
Now, filter out everything that isn't a newline:
tr -dc '\n' /path/to/file | wc -c
You should get back 0.
Or, delete the newlines and count the result.
tr -d '\n' | wc -c
You should get back the same value as in step 1.
wc counts number of '\n' characters in the file. Could it be that your file does not contain one?
Here is the GNU source: https://www.gnu.org/software/cflow/manual/html_node/Source-of-wc-command.html
look for COUNT(c) macro.
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