Skip to main content
LESSON 4 of 5//Stream Processing

Searching with grep

The grep command searches text for patterns. It's one of the most frequently used commands in software development — finding function definitions, hunting for bugs, and searching codebases.

Searching codezsh // interactive
# Search for a string in a file
~grep 'useState' src/App.tsx
const [count, setCount] = useState(0);
# Search recursively with line numbers
~grep -rn 'TODO' src/
src/utils.ts:12: // TODO: add error handling
src/api.ts:45: // TODO: implement caching
# Case-insensitive search
~grep -ri 'error' logs/

Modern alternatives

Try ripgrep (rg) — it's much faster than grep for searching codebases, respects .gitignore, and has better defaults. Install with brew install ripgrep.

PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: