Table of Contents

Shell Data Processing - (WC|Word Count) command (Line count)

About

The wc command is a filter that prints on one line sequentially the number of:

from:

Example

With Standard Input from a pipeline

/bin/echo -e 'Hello\nWorld' > hello.txt
# -e takes the sequence character \n has an end of line
Hello
World

cat hello.txt | wc # read from the input stream created by cat
2       2      12

With Manual Standard Input (Copy / Paste )

wc -

Example when copy/pasting

The wc command is a filter that prints on one line sequentially the number of:

newlines (lines),
words,
and characters

5      20     120 -

With a file as argument

When using a file name as argument

wc hello.txt # transform hello.txt as an input stream and read 
2  2 12 hello.txt

With a glob pattern that select files as argument

with a a glob pattern that select all files that begins with hello

wc hello*
2  2 12 hello.txt
 1  2 12 helloIn.txt
 1  2 12 helloOut.txt
 4  6 36 total

Syntax

wc [OPTION]... [FILE]...

where option can be