‘--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 Exclude Directory

# 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

How can I exclude directories from grep -R?的更多相关文章

  1. shell 命令 grep -R 查询包含指定内容的文件

    grep -R 举个栗子,在有上百个sql文件的目录下,查找使用 spark引擎 执行的文件. 代码是: grep -R spark ./* 返回的就是包含  spark 的sql文件名.

  2. grep -r

    今晚改脚本 我发现了一个很有趣的事情,一共56个配置文件 1 # 注意:对一些参数一致的多个文件可以用此方法 2 # grep -r 查找文件内容,其中PARALLEL=2就是我要替换的内容 3 4 ...

  3. grep时排除指定的文件和目录

    参考:http://winterth.duapp.com/notes/ar03s04.htmlhttp://blog.sina.com.cn/s/blog_7169c8ce0100qkyf.html ...

  4. (转)Linux命令grep

    场景:grep命令在文件搜索中经常会使用到,所以熟练掌握该命令对于日常日志搜索相当有必要! Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.g ...

  5. grep命令中文手册(info grep翻译)

    body { font: 13.34px helvetica, arial, freesans, clean, sans-serif; color: black; line-height: 1.4em ...

  6. grep Pocket Reference读记

    1 简介 grep的基本命令格式如下:           grep [options] [regexp] [filename]   如果regexp中含有空格,应该使用单引号或双引号括起来.单引号和 ...

  7. grep、find命令整理

    一.grep格式: grep [选项]... PATTERN [FILE]...(默认的PATTERN是一个基本的正则表达式(BRE)) 参数选项 1.杂项: -s, --no-messages 不显 ...

  8. Find and Grep

    find 1.格式 Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [ ...

  9. Linux常用命令之-grep

    简介 grep全称Global Regular Expression Print是一种强大的文本搜索工具,它能使用给定的正则表达式按行搜索文本输出,文件,目录等,统计并输出匹配的信息,grep在文本查 ...

随机推荐

  1. UHF桌面式发卡器

    UHF桌面式发卡器: http://www.rr-rfid.com/index.php/pro_view/95  本文用菊子曰发布

  2. android: PendingIntent的使用

    PendingIntent的Flags的类型: * Flags的类型: FLAG_ONE_SHOT:得到的pi只能使用一次,第二次使用该pi时报错 FLAG_NO_CREATE: 当pi不存在时,不创 ...

  3. android: SQLite升级数据库

    如果你足够细心,一定会发现 MyDatabaseHelper 中还有一个空方法呢!没错,onUpgrade() 方法是用于对数据库进行升级的,它在整个数据库的管理工作当中起着非常重要的作用,可 千万不 ...

  4. Apache和tomcat服务器使用ajp_proxy模块

    首先我们先介绍一下为什么要让Apache与Tomcat之间进行连接.事实上Tomcat本身已经提供了HTTP服务,该服务默认的端口是8080,装好tomcat后通过8080端口可以直接使用Tomcat ...

  5. 【地图API】地址录入时如何获得准确的经纬度?淘宝收货地址详解

    用户需求:管理者需要录入一批商户,并在地图上把商户展示出来.但发现一些商户的地址描述并不清楚,导致商户位置出错.如何获得更加准确的商户位置呢? 分析:假设地址准确的,可以通过地址解析,得到准确的经纬度 ...

  6. Android项目实战--手机卫士开发系列教程

    <ignore_js_op> banner131010.jpg (71.4 KB, 下载次数: 0) 下载附件  保存到相册 2 分钟前 上传   Android项目实战--手机卫士01- ...

  7. javaweb 学习总结

    http://www.cnblogs.com/xdp-gacl/category/574705.html 这个总结很好,以前看书没搞懂的,这里基本上都清楚了,赞一个,推荐. Servlet与普通Jav ...

  8. c# 小数取整

    向上取整 math.ceiling() = math.ceiling( math.ceiling( 向下取整 math.) = math. math. C#取整函数实例应用详解 C#取整函数的相关使用 ...

  9. mysql数据库导入和导出

    Mysql数据中,使用时,总是会碰见导入和导出情况,所以如何正确的导入导出,非常重要!下面根据工作中用到的方法,会不管补充: 导入: 直接在Mysql中导入: mysql>use databas ...

  10. .net微信公众号开发——基础接口

    作者:王先荣    本文讲述微信公众号开发中基础接口的使用,包括以下内容:    (1)获取许可令牌(AccessToken):    (2)获取微信服务器地址:    (3)上传.下载多媒体文件:  ...