What is wc
wc means "word count". It counts the lines, words and bytes in files or in piped text.
Syntax
wc [OPTION]... [FILE]...
Options
-c,--bytescounts the bytes.-m,--charscounts the characters.-l,--linescounts the lines (new line characters).-w,--wordscounts the words.-L,--max-line-lengthprints the length of the longest line.--files0-from=Freads the file names from a fileF, separated by NUL characters.--helpshows the help page.--versionshows the version.
Examples
1. Count a file
wc exampleFile.txt

The output shows three numbers and the file name: lines, words and bytes.
12 86 540 exampleFile.txt
2. Count several files
wc exampleFile.txt employeeNames.txt

You get one line per file and a total line at the end.
3. Count the lines
wc -l exampleFile.txt

4. Count the words
wc -w exampleFile.txt

5. Count the characters and bytes
wc -m exampleFile.txt
wc -c exampleFile.txt

The numbers differ when the file has multi-byte characters (like accented letters).
Use wc with other commands
Count the files in a folder:
ls | wc -l
Count the logged-in users:
who | wc -l
Count how many times a word appears as a line in a log:
grep -c "error" app.log
Count the lines of all .py files:
cat *.py | wc -l
Find the longest line:
wc -L file.txt
Quick recap
wc -llines,wc -wwords,wc -cbytes,wc -mcharacters.