New answers tagged

5

@steeldriver's comment is correct: cat shows line-endings with $ (as vi might if you asked it nicely, using ":set list"). The extra character per line is the newline (an invisible character at the end of each line of text). If you want only a count of the printable text, you could filter the file before processing it with wc, e.g., using tr with the -d ...


1

ls -l will display how many files contain the currunt directory and in long format. in total n files +1 line for total X as header. | wc -l counts the total lines that is fed so in total you will have n+1 (lines+(1)header after executing ls -l | wc -l


2

Yes, and also symlinks and sockets. And the first line (there are several questions here about what that number means) will also be counted. But you'll typically only find devices in /dev (with subdirectories) and there's typically very few files there, so I'm wondering if that's really what you want to do. What are you trying to accomplish? Also ls ...


3

No ls -l | wc -l will report the number of lines the ls -l command would give. Roughly the number of files+directories in the current directory plus something for the header.


1

It will show the number of lines output by ls -l which will include everything that has an entry in the current directory, including files (including special files if present), links, and directories.



Top 50 recent answers are included