rg 'pattern' -g '*.js'

Category: Web App Development

rg 'pattern' -g '*.js'

Search only JavaScript files with ripgrep

Finds pattern in files matching the *.js glob, skipping everything else. The -g flag filters by glob and can be repeated, with an exclamation-mark prefix to exclude, like -g '!*.test.js'. ripgrep is the fast, gitignore-aware successor to grep.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.