June 15, 2026 · by Meegrow Labs

What Is the wc Command? Count Lines, Words & Characters

You have a file open and you need a number: how many lines is it? How many words? You could scroll to the bottom and count by hand, but on a file with a few hundred lines that gets old fast.

There is a faster way. One short command in the terminal gives you the answer instantly, no scrolling required.

The wc command counts the lines, words, and characters inside any file, and prints the result in a single line so you never have to count by hand.

What does the wc command do?

The name wc stands for word count, but it actually counts three things at once: lines, words, and characters. You point it at a file, and it tells you what is inside.

Think of it like the word counter on your essay or assignment. The difference is that wc works on any file on your computer, not just a document.

Run it on a file and you get three numbers, in this order: lines, words, characters.

wc notes.txt
      12      48     310 notes.txt

That output means notes.txt has 12 lines, 48 words, and 310 characters. The file name is repeated at the end so you know which file the numbers belong to.

How do I count only the lines?

Most of the time you want just one of those numbers, not all three. You ask for it with a small flag after the command.

To count only the lines, add -l (the letter L, for lines):

wc -l notes.txt
      12 notes.txt

Now you get a clean answer: 12 lines. This is the most common way people use the wc command, because counting lines is so useful for files, logs, and lists.

What are the other wc flags?

The same idea works for words and characters. Each flag asks for one specific count:

  • wc -l — count only the lines
  • wc -w — count only the words
  • wc -c — count only the characters (bytes)

So if you want to know how many words are in an article you saved as a text file, wc -w article.txt gives you that number on its own. No flag at all gives you all three.

Why is the wc command handy?

Because it answers a question you ask all the time, without any clicking or scrolling. How big is this file? How many entries are in this list? Did my export actually save 1,000 rows?

Counting lines is especially useful once you start working with real files. A log file, a list of names, a CSV export — one quick wc -l tells you the size at a glance. It is the kind of small tool you reach for every day without thinking about it.

How do I try the wc command right now?

You do not need anything special. If you have a text file nearby, you can try it in seconds.

Open your terminal and type:

wc -l notes.txt

Replace notes.txt with the name of any file you have. The terminal prints the number of lines and you are done. Try it again with -w and -c to see the words and characters too.

This is one of the small commands that, once you know it, you keep using. It pairs nicely with the other file tools you have met in the free Zero to AI Hero course, where we build up these foundations one short lesson at a time.

Key takeaways

  • The wc command (short for word count) counts lines, words, and characters in a file.
  • Run wc filename to get all three numbers at once, in that order.
  • Use -l for lines, -w for words, and -c for characters.
  • wc -l is the most common use — a fast way to check how big a file is.
  • Try it now: wc -l notes.txt in your terminal prints the line count instantly.

Next up, we put these search and counting tools together to do a little detective work on a file. Keep the streak going.


🚀 Take the full free course: Zero to AI Hero — learn to build with AI from scratch. New lessons daily, in Hindi & English.

Meegrow Labs

We help India go from zero to AI hero — learn to use & build with AI from scratch, in Hindi & English. Start the free course →

Want to actually learn this?

151 free 2-minute lessons — from "what's a file?" to building with AI.

▶ Start the free course