$
Learn Linux handbook
en
XP:0
Quest 26Filterer
+240 XP

Filtering with grep

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

Concept & Overview

Imagine looking through a massive, thousand-page logbook to find every time a system error occurred. Doing this manually would take hours! In Linux, we use grep as our digital magnifying glass to search for specific words or patterns instantly.

- The grep command filters files or piped text, printing only the lines that match your search word. For example, running grep "ERROR" logs.txt scans the file and extracts only the lines containing "ERROR".

Let's filter our logs. Search logs.txt for all lines containing [ERROR] and save them into a new file named errors.log.

Command Syntax Reference

Command / SyntaxDescription
grep "[ERROR]" logs.txtSearch logs.txt for lines containing [ERROR]
grep "[ERROR]" logs.txt > errors.logSave matching errors into errors.log

Verification Objectives

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

  • ○
    Use the "grep" command to search logs.txt
  • ○
    Create file "errors.log" in home directory
  • ○
    Verify errors.log contains only [ERROR] entries

Ready to complete Quest 26?

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