Simple But Useful Samples About 'grep' Command(简单实用的grep 命令)
Do the following:
grep -rnw '/path/to/somewhere/' -e "pattern"
-ror-Ris recursive,-nis line number, and-wstands match the whole word.-l(lower-case L) can be added to just give the file name of matching files.- Along with these,
--excludeor--includeparameter could be used for efficient searching. Something like below:
grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
This will only search through the files which have .c or .h extensions. Similarly a sample use of --exclude:
grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
Above will exclude searching all the files ending with .o extension. Just like exclude file it's possible to exclude/include directories through --exclude-dir and --include-dir parameter; for example, the following shows how to integrate --exclude-dir:
grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
This works very well for me, to achieve almost the same purpose like yours.
For more options :
man grep
Simple But Useful Samples About 'grep' Command(简单实用的grep 命令)的更多相关文章
- 简单实用的Windows命令(二)
昨天简单的记录了几个非常简单实用的Windows命令,不过我又想起来还有两个我在实际的工作中也是经常用到的命令——PING和IPCONFIG,不过我在工作中的使用都是非常简单的,用PING命令检测对应 ...
- 简单实用的Windows命令(一)
前几天新买了一台笔记本电脑,使用了一下几个简单的查看电脑配置的命令,觉得非常的不错,在此记录一下 一:运行命令的方式有两种 1:使用快捷键WIN+R,然后在弹出的“运行”对话框中输入对应的命令 2:在 ...
- Github最简单实用的Git命令指南
create a new repository on the command line echo "# test" >> README.md git init gi ...
- 简单实用的git命令
1.下载项目 先进入目录然后使用jit $ git clone +"url" 2.项目配置 $ composer install 3.上传项目 $ git add . () $ g ...
- Regular Expressions in Grep Command with 10 Examples --reference
Regular expressions are used to search and manipulate the text, based on the patterns. Most of the L ...
- 15 Practical Grep Command Examples In Linux / UNIX
You should get a grip on the Linux grep command. This is part of the on-going 15 Examples series, wh ...
- grep的简单理解
概述: grep最早由肯·汤普逊写成.原先是ed下的一个应用程序,名称来自于g/re/p(globally search a regular expression and print,以正则进行全域查 ...
- Linux下好用的简单实用命令
1.你是否为在输入了一大串命令之后发现第一个字符打错了而苦恼?只能删除重来嘛?或者一步步左移光标? NO,一个组合键轻松搞定 Ctrl+A -----到命令行首 Ctrl+E ------到命令行末 ...
- Linux的简单介绍和常用命令的介绍
Linux的简单介绍和常用命令的介绍 本说明以Ubuntu系统为例 Ubuntu系统的安装自行百度,或者参考http://www.cnblogs.com/CoderJYF/p/6091068.html ...
随机推荐
- Save Update saveOrUpdate delete
参考:Hibernate Session的saveOrUpdate()方法 saveOrUpdate与Update的作用 Hibernate Delete query Hibernate Basics ...
- ios空模板配置
ios之Xcode6如何手动创建空工程模板 1.首先创建Single View Application 2.然后找到工程目录->Supporting Files ——>找到 info.pl ...
- c# listview的使用
C#向listview中添加项
- 抓取网页中数据 -----51book中城市码
================== 获取网页中span标签里面的t_id的值 public function getpreg(){ $www = 'http://monkey.test.tripb. ...
- Git子模块引用外部项目
Git子模块(submodule)简介 经常有这样的事情,当你在一个项目上工作时,你需要在其中使用另外一个项目.也许它是一个第三方开发的库或者是你独立开发和并在多个父项目中使用的.这个场景下一个常见的 ...
- 此 ObjectContext 实例已释放,不可再用于需要连接的操作
EF 查询包含导航属性的Model,经常会遇到 此 ObjectContext 实例已释放,不可再用于需要连接的操作 这种错误,解决方法如下: db.T_DailyRecord.Include(&qu ...
- 图片拉伸:resizableImageWithCapInsets
iOS 5.0 在iOS 5.0中,UIImage有一个新方法可以处理图片的拉伸问题 - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)ca ...
- C# 将List中的数据导入csv文件中
//http://www.cnblogs.com/mingmingruyuedlut/archive/2013/01/20/2849906.html C# 将List中的数据导入csv文件中 将数 ...
- erlang ets表
一.表遍历 通过ets:first/1获取表的第一个关键字,表中下一个关键字用ets:next/2得到,直到ets:next/2返回'$end_of_table' 当多几个进程并发访问ets表时,可以 ...
- 启动tomcat时报错:java.lang.OutOfMemoryError: PermGen space
1.修改myeclipse.ini 在Myeclipse安装目录下G:\MyEclipse8.5\Genuitec\MyEclipse 8.5有一个myeclipse.ini配置文件,设置如下: -v ...