Simple But Useful Samples About 'grep' Command(简单实用的grep 命令)
Do the following:
grep -rnw '/path/to/somewhere/' -e "pattern"
-r
or-R
is recursive,-n
is line number, and-w
stands match the whole word.-l
(lower-case L) can be added to just give the file name of matching files.- Along with these,
--exclude
or--include
parameter 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 ...
随机推荐
- HDU 1008 u Calculate e
Problem Description A simple mathematical formula for e is where n is allowed to go to infinity. Thi ...
- CSS3秘笈复习:第十一章
1.text-align与vertical-align: text-align控制水平方向的定位,关键字是left.right.center和justify. vertical-align控制垂直方向 ...
- Animate.css让添加CSS动画像喝水一样容易
在这个年代,你要是不懂一点点css3的知识,你都不好意思说你是个美工.美你妹啊,请叫我前端工程师好不好.呃..好吧,攻城尸...呵呵,作为一个攻城尸,没有点高端大气上档次的东西怎么能行呢,那么css3 ...
- hdu_5831_Rikka with Parenthesis II(模拟)
题目链接:hdu_5831_Rikka with Parenthesis II 题意: 给你一些括号的排列,必须交换一次,能不能将全部的括号匹配 题解: 模拟一下括号的匹配就行了,注意要特判只有一对括 ...
- Java实现二分查找算法
Java程序员总该玩点基本的算法. 1.前提:二分查找的前提是需要查找的数组必须是已排序的,我们这里的实现默认为升序 2.原理:将数组分为三部分,依次是中值(所谓的中值就是数组中间位置的那个值)前,中 ...
- [ An Ac a Day ^_^ ] CodeForces 426C Sereja and Swaps 优先队列
题意: 给你一个有n个数的序列 取一个区间 这个区间内的数可以与区间外的值交换k次 问这样的区间最大值是多少 思路: 看数据是200 时间复杂度O(n*n) 应该可以暴力 顺便学习一下优先队列 枚举区 ...
- NOIP2010-普及组复赛模拟试题-第一题-手机
题目背景 Background 现在手机使用越来越广泛了 题目描述 Description 一般的手机的键盘是这样的: 要按出英文字母就必须要按数字键多下.例如要按出 x 就得按 9 两下,第一 ...
- G - 小晴天老师系列——可恶的墨水瓶
G - 小晴天老师系列——可恶的墨水瓶 Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Othe ...
- Servie之前台Service
public class MyService extends Service { public static final String TAG = "MyService"; pri ...
- VBS操作JS网页元素实例
'=========================================================================='' VBScript Source File - ...