Skip to content
Back to the catalog
Project grepToolingBeginnerBeta

Build your own grep

Read stdin, filter by pattern and honour exit codes. The gateway to Unix tooling.

Build it in your language

The tester treats your program as a black box: any language works. These are just the most convenient ones for this project.

Guide language

The stage guides read in this language. Only languages this project is fully translated into show up here; the interface language does not change.

What this project is about

grep is the perfect Unix tool: it does one thing, it does it fast, and it composes with everything else. Rebuilding it teaches as much about design philosophy as it does about code.

You'll build a clone that searches by pattern in stdin and in files, with the flags you actually use (-i, -v, -n, -c, -r), and with correct behaviour in the part nobody looks at but everybody depends on: exit codes.

Roadmap

7 stages across 3 phases. Every stage comes with its guide and its tests: you move on when they pass.

  1. Phase 12 stages

    Filtering lines

    Read stdin, search for a literal string and print the matches.

    1. 01Literal search
    2. 02stdin and exit status
  2. Phase 23 stages

    Flags and files

    -i, -v, -n, -c, several files at once, and correct exit codes.

    1. 01Case-insensitive matching
    2. 02Invert and number
    3. 03Counting and multiple files
  3. Phase 32 stages

    Patterns and recursion

    Character classes, anchors and recursive directory search.

    1. 01Classes and anchors
    2. 02Recursive traversal

Before you start

A command-line tool that filters lines by pattern: reading from stdin and from files, literal and basic regular expression search, the common flags, recursive directory search, coloured output and exit codes compatible with grep.

  • coding-agent
    Beta

    Build a Coding Agent

    Learn the core foundations of AI coding assistants from scratch: model basics, API key security, why use OpenRouter as a universal model router, tool schemas, and the autonomous ReAct loop.

    Beginner7 stages~6 hTooling
    agentopenrouterllm+3

    Python · TypeScript

  • git
    Beta

    Build your own Git

    Blobs, trees and commits. Discover that Git is a content-addressed object store, and little else.

    Advanced12 stages~18 hTooling
    hashingzlibdag+1

    Go · Python · Rust