$
Learn Linux handbook
en
XP:0
Quest 24Plumber
+230 XP

Introduction to Pipes & wc

Launch Interactive Terminal for This Quest→No installation required • Runs fully in browser

Concept & Overview

Imagine an assembly line where one worker wraps a product and immediately hands it to the next worker to pack it into a box—no intermediate storage needed. In Linux, we connect commands exactly like this using a pipe (|).

- A pipe (|) routes the output of one command directly into the input of the next command. For example, ls | wc -l lists files and immediately hands that list to wc -l (word count - lines), which counts them up on the fly without needing temporary files.

Why this matters: If you run wc without -l, it outputs three separate numbers: lines, words, and bytes (e.g., 5 10 85). This makes it difficult to use in pipelines or scripts that need a clean, single-number count. The -l flag limits the output to just the line count.

Let's connect some commands. Count the files in /home/learner using a pipe (ls | wc -l), and write the final count into a file named file_count.txt using > redirection.

Command Syntax Reference

Command / SyntaxDescription
ls | wc -lCount files and folders in current directory
ls | wc -l > file_count.txtWrite files count to file_count.txt

Verification Objectives

These conditions will be automatically verified when you run commands inside the interactive terminal simulator:

  • ○
    Use pipe (|) to connect ls with wc
  • ○
    Create file "file_count.txt" in home directory
  • ○
    Verify file contains the correct numeric file count

Ready to complete Quest 24?

Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.