grep versus glob
These two solve genuinely different problems that are easy to conflate at a glance. grep looks inside file contents for a pattern, useful when you know roughly what text or code you are looking for but not which file it actually lives in.
glob looks at file names themselves, useful when you know the shape of a file you want, every test file, every config file, but not its exact path within the project.
A single investigation frequently uses both in sequence rather than picking one: narrow down which files are even relevant with glob first, then search inside that narrower set with grep to find the specific line that matters.
| grep | glob | |
|---|---|---|
| Searches | File contents | File names |
| Best when | You know roughly what text or code to look for | You know the shape of the file, not its exact path |
| Example | grep "retry_count" | glob "**/*.test.ts" |
Neither tool is a substitute for the other in the cases where they genuinely differ; a grep for a file name pattern would search inside files for that literal text rather than matching file names, and a glob for a piece of code content simply would not match anything, since it never looks inside files at all.