ShellProven
Lesson 02 · tested on Debian 13

Search a whole project with grep -r, without node_modules, .git or binary junk

Search a whole project for a string with grep -r, then cut the noise: skip node_modules, .git and build folders with --exclude-dir, ignore binary files with -I, search only one file type with --include, match whole words with -w, and stop dots from acting as wildcards with -F.

Video coming soon — @ShellProven

Commands

Exactly as run in the video. Full folder with setup script and log: terminal-tutorials/grep-r-excludes.

# The noisy first search
$ grep -r "TODO" .
./src/client.js:// TODO: handle errors
./src/auth.py:    # TODO: rate limit
./.git/config:	# TODO nothing
./node_modules/left-pad/index.js:// TODO upstream bug
./dist/app.min.js:function a(){/*TODO*/return 1}
grep: ./bin/tool: binary file matches

# Skip folders with --exclude-dir
$ grep -rn "TODO" --exclude-dir=node_modules --exclude-dir=.git .
./src/client.js:1:// TODO: handle errors
./src/auth.py:2:    # TODO: rate limit
./dist/app.min.js:1:function a(){/*TODO*/return 1}
grep: ./bin/tool: binary file matches

# Ignore binary files with -I
$ grep -rnI "TODO" --exclude-dir={node_modules,.git,dist} .
./src/client.js:1:// TODO: handle errors
./src/auth.py:2:    # TODO: rate limit

# Case, file types and file names
$ grep -rniI "todo" --exclude-dir={node_modules,.git,dist} .
./src/main.py:2:# todo: remove debug flag
./src/client.js:1:// TODO: handle errors
./src/auth.py:2:    # TODO: rate limit
$ grep -rl "TODO" --include="*.py" .
./src/auth.py

# Whole words with -w
$ grep -rn "log" logs src
logs/app.log:1:2026 login ok
logs/app.log:2:2026 user log out
src/client.js:2:fetch("/api/catalog")
src/auth.py:1:def login(user):
$ grep -rnw "log" logs src
logs/app.log:2:2026 user log out

# Dots are wildcards: use -F
$ grep -rn "1.5" src logs
src/main.py:4:VERSION = "1.5"
logs/app.log:3:version 105 started
$ grep -rnF "1.5" src logs
src/main.py:4:VERSION = "1.5"

# Several patterns and some context
$ grep -rnIE "TODO|FIXME|DEBUG" --exclude-dir={node_modules,.git,dist} .
./src/main.py:3:DEBUG = True
./src/client.js:1:// TODO: handle errors
./src/auth.py:2:    # TODO: rate limit
$ grep -n -A 1 "TODO" src/auth.py
2:    # TODO: rate limit
3-    return check(user)

Quick check

Same two questions as in the video. Checked here, in your browser — nothing is sent anywhere.

Transparency. Script and narration made with AI, human-reviewed. The robot and the dog are AI-generated cartoon characters. The commands and their output are real runs in a container.