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 ...
随机推荐
- Node.js:url
在node运行环境中输入url: > url url { parse: [Function: urlParse], resolve: [Function: urlResolve], resolv ...
- Java IO 理解流的概念
Java IO 理解流的概念 @author ixenos 在理解流时首先理解以下概念 1.流的来源和去向一般在构造器指出 2.方法中的形参一般是将流输出到某个位置,读取(INPUT)流从流读出数据( ...
- Maxmum subsequence sum problem
We have a lot of ways to solve the maximum subsequence sum problem, but different ways take differen ...
- luci编译错误
make[3]: Entering directory '/home/hbg/test1214/package/feeds/luci/luci'*** Repository layout change ...
- LeetCode OJ 64. Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...
- Web调用安卓,苹果手机摄像头,本地图片和文件
由于要给一个客户做一个记账WAP,里面有调用手机拍照功能,这里记录一下,以供需要的朋友,下面是完整的一个HTML页面内容,放在服务器上然后浏览就可以了,只支持Chrome和Safari核的浏览器,我测 ...
- chapter 12_2 保存无环的table
保存table有几种方法,选用哪种方法取决于对table的结构作出了哪些限制性的假设 第一个方法: function serialize(o) if type(o) == "number&q ...
- tableviewcell 中使用autolayout自适应高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { [ce ...
- socket通信实例
ref: http://www.cnblogs.com/xudong-bupt/archive/2013/12/29/3483059.html http://blog.csdn.net/love_ga ...
- xp添加右键"打开文件所在位置"
以下代码保存为czmb.vbs文件并放在C:\windwos目录下: Set OS = GetObject("winmgmts:\\.\root\cimv2")Set CF = O ...