Linux wc command
wc prints newline, word, and byte counts for each FILE, and a total if more than one FILE is specified. With no FILE, or when FILE is a dash ("-"), wc operates on standard input. (A word is a non-zero-length sequence of characters delimited by white space.)
The options below may be used to select which counts are printed. Counts are always in the following order: newline, word, character, byte, maximum line length.
wc [OPTION]... [FILE]...
wc [OPTION]... --files0-from=F
|-c, --bytes||Print the byte counts.|
|-m, --chars||Print the character counts.|
|-l, --lines||Print the newline counts.|
|--files0-from=F||Read input from the files specified by null-terminated names in file F; if F is "-" then read names from standard input.|
|-L, --max-line-length||Print the length of the longest line.|
|-w, --words||Print the word counts.|
|--help||Display a help message, and exit.|
|--version||Output version information, and exit.|
Displays information about the file myfile.txt. Output resembles the following:
5 13 57 myfile.txt
Where 5 is the number of lines, 13 is the number of words, and 57 is the number of characters.
ls -1 | wc -l
This command returns the number of objects in the current directory. It uses the ls command to produce a single-column (-1) listing of the directory contents, which outputs one line per object; this output is piped to wc, which counts the lines (-l), and returns that number.