Stage 3 · Lesson 2 of 8
Searching text with grep
searches text and prints the lines that match a pattern. A few cover daily use. -i ignores upper and lower case.
-n adds line numbers. -r searches a whole folder and everything inside it. -v shows the lines that do not match.
-l lists only the file names, -c counts matching lines and -E turns on extended . For example, grep -rn "TODO" src/ finds every TODO in src with its file and line. Inside a pipeline, grep filters the output of other commands. Many developers also install ripgrep (rg), which is faster and skips files ignores.
Common trapforgetting to quote a pattern that contains spaces or special characters.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CourseFreeThe Missing Semester of Your CS Education
MIT · Beginner
The data wrangling lecture walks through grep, sed, awk and regular expressions on real logs
- BookFreeThe Linux Command Line
William Shotts · Beginner
Clear chapters on text processing, regular expressions and searching for files