The word count (wc) command is used to count the number of lines, words, and characters in a text file. If multiple files are specified, then the command displays the counts for each file and the total count for all files.

wc command examples in Linux

Syntax

The syntax of the wc command is:

# wc [options] {file names}

wc Command Options

The wc command provides various options that enable you to specify the nature of the output.

Option Used To
-c Display the byte count.
-m Display the character count.
-l Display the newline count.
-w Display the word count.

wc Command Examples

1. To see no of lines from a file:

2. To count the bytes:

3. To get no of characters:

4. To get the no of words:

5. To get the length of longest line:

6. To get the version: