Restrict matches to paths matching a glob.
Section: Glob filters
Search only JavaScript files
bash
bash
rg --glob '*.js' 'fetch\(' .Explanation
Use glob filters when file types alone are too broad or when you want path-specific targeting.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Glob filters
Combine several globs
Layer multiple includes and excludes in one command.
Explain ignore and glob decisions
Inspect why paths are included or excluded.