search but skip some files

grep through a project without its build folders, minified files or logs.

  • text
  • search

Steps

  1. grep -rn --exclude-dir={.git,node_modules,dist} 'text' .

    skip those folders

  2. grep -rn --include='*.js' --include='*.ts' 'text' .

    only those kinds of files

  3. grep -rn --exclude='*.min.js' 'text' .

    skip files by name

  4. rg 'text' -g '!*.min.js'

    ripgrep: skips .gitignore's files already; -g adds more

Commands used

  • grep
  • rg

Each has a page in lore: lore grep opens it.