Module lessons (2/2)
Pipelines and filters (grep and |)
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 thestdoutof the first into thestdinof the second. - Filter log and configuration lines with
grep, applying-i(ignore-case),-v(invert), and-n(line numbers). - Combine file reading,
grepfiltering, 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
- 1Pipeline anatomy and
grepoptions - 2Progressive examples
- 3Practical exercises
- 4Quick check
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.