ArticleslgStudy

science

Wc (Unix)

Wc (Unix) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Wc (Unix) rather than just read about it. In short: wc (short for word count) is a command in Unix, Plan 9, Inferno, and operating systems that are Unix-like. The program reads either standard input or a list of computer files and generates one or more of the following statistics: newline count, word count, and byte count.

Wc (Unix) — main illustration
Wc (Unix) — illustration

Key takeaways

  • Wc (Unix) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Wc (Unix) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Wc (Unix) from memory before moving on to harder problems.

Reference excerpt

wc (short for word count) is a command in Unix, Plan 9, Inferno, and operating systems that are Unix-like. The program reads either standard input or a list of computer files and generates one or more of the following statistics: newline count, word count, and byte count. If a list of files is provided, both individual file and total statistics follow.

Example Sample execution of wc:

The first column is the count of newlines, meaning that the text file foo has 40 newlines while bar has 2294 newlines- resulting in a total of 2334 newlines. The second column indicates the number of words in each text file showing that there are 149 words in foo and 16638 words in bar – giving a total of 16787 words. The last column indicates the number of characters in each text file, meaning that the file foo has 947 characters while bar has 97724 characters – 98671 characters all in all. Newer versions of wc can differentiate between byte and character count. This difference arises with Unicode which includes multi-byte characters. The desired behaviour is selected with the -c or -m options. Through a pipeline, it can also be used to preview the output size of a command with a potentially large output, without it printing the text into the console:

History wc is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification. It appeared in Version 1 Unix. GNU wc used to be part of the GNU textutils package; it is now part of GNU coreutils. The version of wc bundled in GNU coreutils was written by Paul Rubin and David MacKenzie. A wc command is also part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2. The command is available as a separate package for Microsoft Windows as part of the GnuWin32 project and the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities. The wc command has also been ported to the IBM i operating system.

Usage wc -c <filename> prints the byte count wc -l <filename> prints the line count wc -m <filename> prints the character count wc -w <filename> prints the word count wc -L <filename> prints the length of the longest line (GNU extension)

See also List of Unix commands

References

External links

wc(1) - Original Unix First Edition manual page for wc. wc(1) – Linux User Commands Manual wc(1) – Plan 9 Programmer's Manual, Volume 1 wc(1) – Inferno General commands Manual The wc Command by The Linux Information Project (LINFO)

Illustrations

Wc (Unix) illustration

Worked examples

Example 1 — a first encounter with Wc (Unix)

Start with the simplest possible case. Write down what Wc (Unix) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Wc (Unix) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Wc (Unix) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Wc (Unix)

In research
Wc (Unix) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Wc (Unix) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Wc (Unix) is common in secondary-school and first-year university syllabi. It links to neighbouring topics IBM i Qshell commands, Inferno (operating system) commands, Plan 9 commands, so understanding it makes those chapters shorter.
In everyday life
Look for Wc (Unix) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Wc (Unix)” →

How to study Wc (Unix) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Wc (Unix) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Wc (Unix) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Wc (Unix) in simple terms?

wc (short for word count) is a command in Unix, Plan 9, Inferno, and operating systems that are Unix-like. The program reads either standard input or a list of computer files and generates one or more of the following statistics: newline count, word count, and byte count.

Why does Wc (Unix) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Wc (Unix)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Wc (Unix).

Tags

  • IBM i Qshell commands
  • Inferno (operating system) commands
  • Plan 9 commands
  • Unix SUS2008 utilities
  • Unix text processing utilities

Keep exploring