The "wc" Utility
The "wc" utility is used to count the number of words, characters or lines in a file and includes several useful options.
Consider these examples of options in use
Another cool way to use "wc" is to count the number of files in a directory by piping the output of "ls" to "wc" such as:
ls -l | wc -l
Finally, as with other commands, you can use the back tick (`) character to perform command substitution. Thus, the following command will count the number of files in the current directory and the one just above it. (Note you may have to subtract any header lines depending on your version of "ls" as in the version shown below in which we need to extract the lines total 5 and total 8)
expr `ls -l | wc -l` + `ls -l .. | wc -l`