Skip to main content
Module 3 · Lesson 2 of 27/11 in the course~21 min
Module lessons (2/2)

Pipelines and filters (grep and |)

Lesson preview5 hands-on exercises readyLinux Terminal · Module 3 — Streams, Redirects, and Filters

Pipe the output of one command into another and run targeted search filters with grep.

What you'll learn in this lesson

  • Connect different commands in sequence via pipeline (|) passing the stdout of the first into the stdin of the second.
  • Filter log and configuration lines with grep, applying -i (ignore-case), -v (invert), and -n (line numbers).
  • Combine file reading, grep filtering, and disk redirection to quickly extract useful data from huge files.

Overview

The Unix philosophy can be summed up in one sentence: write programs that do one thing well and can collaborate via streams of text. The pipeline turns the terminal into an assembly line: the textual output of one command immediately becomes the input of the next command, without creating temporary files.

When the input comes from a previous command rather than a single file, grep automatically reads from the standard input linked by the vertical bar:

Sections covered in this lesson

  1. 1Pipeline anatomy and grep options
  2. 2Progressive examples
  3. 3Practical exercises
  4. 4Quick check
Pro Lesson · Module 3 — Streams, Redirects, and Filters

Unlock "Pipelines and filters (grep and |)" and the full Linux Terminal curriculum

Pipe the output of one command into another and run targeted search filters with grep.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Linux Terminal plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.