# How to use the linux wc command

> Canonical: https://jethost.com/kb/how-to-use-the-linux-wc-command/ · Last modified: 2026-08-20T06:50:29+00:00

The **Linux wc command** (word count) quickly reports how many lines, words, and bytes a file contains. It is simple, fast, and especially useful in scripts and pipelines when you need to count something. In this article, we will show you the basic usage of the Linux wc command with examples.

### Basic wc usage

First, run `wc` with a filename. It prints three numbers – lines, words, and bytes – followed by the filename:

```
wc myFile.txt
## => 12 84 560 myFile.txt
```

### Count lines, words, or characters

Next, add a flag to show just one figure. This keeps output clean when you only need a single number:

- `wc -l` – count lines.
- `wc -w` – count words.
- `wc -c` – count bytes.
- `wc -m` – count characters.

```
wc -l access.log
## => 1543 access.log
```

### Count across several files

Additionally, you can pass several files or a wildcard. The wc command lists each file and adds a *total* line at the end:

```
wc -l *.txt
```

### Use wc in a pipeline

Finally, wc is at its best when it counts the output of another command. For example, count how many processes match a name, or how many files are in a folder:

```
ls | wc -l
grep "error" app.log | wc -l
```

When you pipe input into it, the Linux wc command counts that stream instead of a file, so the filename is omitted from the output. This is why `ls | wc -l` gives you a plain count of items in the current directory. A quick tip: `-c` counts bytes while `-m` counts characters, and the two differ for files that use multi-byte encodings such as UTF-8. Because wc only reads data, it is completely safe to run at any time, making it a handy building block in your everyday commands.

### Need more help?

Explore more [Linux commands](https://jethost.com/kb/category/linux-commands/) with examples on an [SSH shared hosting](https://jethost.com/web-hosting/) account, or get full root control with a [JetHost VPS](https://jethost.com/vps/).
