wc

>Usage

The wc command stands for "word count." It is used to count the number of lines, words, and bytes (or characters) in a file or standard input. This command is particularly useful for obtaining quick statistics about text files.

>Syntax

wc [options] file

>Options

-l

Count lines only.

-w

Count words only.

-c

Count bytes only.

-m

Count characters (useful for multi-byte character sets).

-L

Display the length of the longest line.

>Examples

Example 1:

Dots

-zsh

> wc example.txt


10 150 1024 example.txt (number of lines: 10; words: 150; bytes: 1024)

Example 2:

Dots

-zsh

> wc -l example.txt


10 example.txt (number of lines in file example.txt)

Example 3:

Dots

-zsh

> wc file1.txt file2.txt


10 150 1024 file1.txt      count lines, words,                            and bytes
                           in file1.txt
20 300 2048 file2.txt      count lines, words,                            and bytes
                           in file2.txt
30 450 3072 total          count lines, words,                            and bytes
                           in both files

>Quiz

Progress: Question ? out of ?

Question Title

Page written by Gokhan YILMAZ