search but skip some files
grep through a project without its build folders, minified files or logs.
Steps
-
grep -rn --exclude-dir={.git,node_modules,dist} 'text' .skip those folders
-
grep -rn --include='*.js' --include='*.ts' 'text' .only those kinds of files
-
grep -rn --exclude='*.min.js' 'text' .skip files by name
-
rg 'text' -g '!*.min.js'ripgrep: skips .gitignore's files already; -g adds more
Commands used
greprg
Each has a page in lore: lore grep opens it.
Related recipes
- find files containing a textSearch every file under a folder for a word or a phrase, and show where it is.
- add up numbers in a fileSum a column of numbers, from a file or a command's output.
- compare two foldersFind which files differ between two folders, or are only in one of them.
- count lines of codeHow many lines of code a project has, in total and by language.