‘--exclude-dir=dir’
    Exclude directories matching the pattern dir from recursive directory searches. 
 

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

‘--exclude-dir=dir’
    Exclude 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 -Ri --exclude-dir "/var/www/directory_to_exclude" "search pattern" /var/www
Or multiple directories:# grep -Ri --exclude-dir "/var/www/directory_to_exclude" --exclude-dir "/var/www/another_directory_to_exclude" "search pattern" /var/www
Or wildcard:
# grep -Ri --exclude-dir "*.svn" "search pattern" *
Or with only exclude: # grep -Rli --exclude="*\.svn*" "search string" /var/www

相关文章:

  • 2021-09-29
  • 2021-10-10
  • 2021-06-10
  • 2021-05-22
  • 2021-07-04
  • 2021-11-27
  • 2021-10-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2021-09-23
  • 2021-11-29
  • 2021-10-17
相关资源
相似解决方案