Linux for Programmers and Users

[Page 67 (continued)]

3.25. Counting Words in a File: wc

I was quite interested to find out how many characters, words, and lines were in the "heart.final" file (even though printing it gave me a byte count). To do this, I used the wc utility, described in Figure 3-32.

Figure 3-32. Description of the wc command.

Utility: wc -lwc { fileName }*

The wc utility counts the lines, words, and/or characters in a list of files. If no files are specified, standard input is used instead. The -l option requests a line count, the -w option requests a word count, and the -c option requests a character count. If no options are specified, then all three counts are displayed. A word is defined by a sequence of characters surrounded by tabs, spaces, or newlines.

Here's an example of wc:

$ wc heart.final ...obtain a word count. 9 43 213 heart.final $ _

Категории