bash wc - ghdrako/doc_snipets GitHub Wiki

$ wc file1 file2 file3

The numbers of lines, words and characters for each file along with its name will be displayed on a separate line and in the order that the files are listed as arguments (i.e., input files). In the case of multiple arguments such as this, wc also provides an additional line that shows the total number of lines, words and characters for all the files.

$ wc . *

Provide a count for all of the text files within a current directory

$wc -w file4

displays just the number of words in a file named file4

$wc -lw file5

displays both the number of words and lines in a file named file5

ls | wc -l

As another example, wc with its -l option can be used to count the total number of objects (i.e., files, links and directories) in the current directory.