Skip to main content
Add Bash syntax highlighting
Source Link
Benjamin Loison
  • 5.8k
  • 4
  • 20
  • 37

Recent versions of GNU Grep (>= 2.5.2) provide:

--exclude-dir=dir  

which excludes directories matching the pattern dir from recursive directory searches.

So you can do:

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 
grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 

For a bit more information regarding syntax and usage see

For older GNU Greps and POSIX Grep, use find as suggested in other answers.

Or just use ack (Edit: or The Silver Searcher) and be done with it!

Recent versions of GNU Grep (>= 2.5.2) provide:

--exclude-dir=dir  

which excludes directories matching the pattern dir from recursive directory searches.

So you can do:

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 

For a bit more information regarding syntax and usage see

For older GNU Greps and POSIX Grep, use find as suggested in other answers.

Or just use ack (Edit: or The Silver Searcher) and be done with it!

Recent versions of GNU Grep (>= 2.5.2) provide:

--exclude-dir=dir 

which excludes directories matching the pattern dir from recursive directory searches.

So you can do:

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 

For a bit more information regarding syntax and usage see

For older GNU Greps and POSIX Grep, use find as suggested in other answers.

Or just use ack (Edit: or The Silver Searcher) and be done with it!

Remove reference to Docs
Source Link
Jonathan Leffler
  • 759.5k
  • 145
  • 961
  • 1.3k

Recent versions of GNU Grep (>= 2.5.2) provide:

--exclude-dir=dir 

which excludes directories matching the pattern dir from recursive directory searches.

So you can do:

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 

For a bit more information regarding syntax and usage see

For older GNU Greps and POSIX Grep, use find as suggested in other answers.

Or just use ack (Edit: or The Silver Searcher) and be done with it!

Recent versions of GNU Grep (>= 2.5.2) provide:

--exclude-dir=dir 

which excludes directories matching the pattern dir from recursive directory searches.

So you can do:

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 

For a bit more information regarding syntax and usage see

For older GNU Greps and POSIX Grep, use find as suggested in other answers.

Or just use ack (Edit: or The Silver Searcher) and be done with it!

Recent versions of GNU Grep (>= 2.5.2) provide:

--exclude-dir=dir 

which excludes directories matching the pattern dir from recursive directory searches.

So you can do:

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 

For a bit more information regarding syntax and usage see

For older GNU Greps and POSIX Grep, use find as suggested in other answers.

Or just use ack (Edit: or The Silver Searcher) and be done with it!

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Recent versions of GNU Grep (>= 2.5.2) provide:

--exclude-dir=dir 

which excludes directories matching the pattern dir from recursive directory searches.

So you can do:

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 

For a bit more information regarding syntax and usage see

For older GNU Greps and POSIX Grep, use find as suggested in other answers.

Or just use ack (Edit: or The Silver Searcher) and be done with it!

Recent versions of GNU Grep (>= 2.5.2) provide:

--exclude-dir=dir 

which excludes directories matching the pattern dir from recursive directory searches.

So you can do:

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 

For a bit more information regarding syntax and usage see

For older GNU Greps and POSIX Grep, use find as suggested in other answers.

Or just use ack (Edit: or The Silver Searcher) and be done with it!

Recent versions of GNU Grep (>= 2.5.2) provide:

--exclude-dir=dir 

which excludes directories matching the pattern dir from recursive directory searches.

So you can do:

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search 

For a bit more information regarding syntax and usage see

For older GNU Greps and POSIX Grep, use find as suggested in other answers.

Or just use ack (Edit: or The Silver Searcher) and be done with it!

add link to stackoverflow docs on excluding directory to existing list of references; the stackoverflow docs turn out to be a bit more compact and readable than the other references
Source Link
Loading
added 11 characters in body
Source Link
nbro
  • 16.1k
  • 34
  • 122
  • 219
Loading
Add link to The Silver Searcher
Source Link
johnsyweb
  • 142.9k
  • 26
  • 197
  • 253
Loading
Added version information (with a git link)
Source Link
johnsyweb
  • 142.9k
  • 26
  • 197
  • 253
Loading
Source Link
johnsyweb
  • 142.9k
  • 26
  • 197
  • 253
Loading