← Lessons/Pipes & Filters
← Pipes & Filters

Count the requests

Learn

Commands read and write text

Every command has two text streams: it reads from standard input (stdin) and writes to standard output (stdout). By default stdout goes to your screen, which is why you see a command's answer as soon as it finishes.

Your first tool is wc, short for word count. On its own it prints lines, words and bytes; -l switches it to lines only:

wc -l access.log
#  5 access.log

It prints the count, then the file it counted. A log has one request per line, so counting lines counts requests: a quick answer to "how busy was the server?"

This sandbox has an access.log with a few requests in it. Type a single command into the terminal and press Enter.

How many requests are in access.log? Count its lines with wc -l.

sandbox@opspath: ~
OpsPath sandbox · Debian GNU/Linux 12 · GNU bash 5.2
Each command runs in a fresh, isolated sandbox with this lesson's files in ~.
Nothing carries over between commands, so chain with && or | when you need to.
Type a command and press Enter. ↑/↓ history · Ctrl+L clear · Ctrl+C cancel line
# ── Step 1 · Count the requests ──
# Sign in to run commands — it's free.