Linux and Unix wc command
Short for word count, wc displays a count of lines, words, and characters in a file.
wc [-c | -m | -C ] [-l] [-w] [ file ... ]
|-C||Same as -m.|
|-w||Count words delimited by white space characters or new line characters. Delimiting characters are Extended Unix Code (EUC) characters from any code set defined by iswspace()|
|file||Name of file to word count.|
Displays information about the file myfile.txt. Below is an example of the output.
5 13 57 myfile.txt
5 = Lines
13 = Words
57 = Characters
ls -1 | wc -l
Count how many files and directories are in the current directory. To prevent any confusion, the above command reads ls <dash><the #1> <pipe> wc <dash><the letter l>. This command uses the ls command to list files in a bare format and pipes the output into the wc command to count how many files are listed. When done properly, the terminal should return a single number indicating how many lines were counted and then return you to the prompt.
Tip: Keep in mind that this is also counting the ./ and ../ directories.