grep简单介绍

正如linux的man文件里所描写叙述的那样:

grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.

In addition, two variant programs egrep and fgrep are available. egrep is the same as grep -E. fgrep is the same as grep -F. Direct invocation as either egrep or fgrep is deprecated, but is provided to allow historical applications that rely on them to run unmodified.

grep是用来在一个文件里查找和给定的模式相匹配的行的命令,同一时候egrep 和 fgrep都已经被弃用。取而代之的是 grep -E和grep -F。

用法

在单个文件里搜索包括字符串的行

语法:

grep “literal_string” filename

在多个文件里搜索包括字符串的行

语法:

grep “this” demo_*

注:这个的搜索域是demo_为前缀的文件

使用 -i 參数能够实现大写和小写无关

能够使用正則表達式来过滤

语法:

grep “REGEX” filename

详细用法能够參考:http://www.cnblogs.com/kuyuecs/archive/2012/07/13/2589988.html

写得非常不错的博客。

$(function () {
$('pre.prettyprint code').each(function () {
var lines = $(this).text().split('\n').length;
var $numbering = $('

    ').addClass('pre-numbering').hide();
    $(this).addClass('has-numbering').parent().append($numbering);
    for (i = 1; i ').text(i));
    };
    $numbering.fadeIn(1700);
    });
    });

grep经常使用使用方法的更多相关文章

  1. Grep查看日志的方法【转】

    转自:http://blog.csdn.net/stormkey/article/details/5905204 版权声明 :转载时请以超链接形式标明文章原始出处和作者信息及本声明 http://go ...

  2. shell使用ps -ef|grep xxx时不显示grep xxx进程的方法

    在使用ps -ef|grep xxx时会将grep xxx的进程也带出来, 而在脚本中如果想要截取此命令结果的一部分,则grep xxx的进程会显得多余,如下: [root@localhost ~]# ...

  3. Jquery 遍历数组之grep()方法介绍

    grep()方法用于数组元素过滤筛选. grep(array,callback,boolean);方法参数介绍. array   ---待处理数组 callback  ---这个回调函数用来处理数组中 ...

  4. Linux 查找已安装软件的方法

    1.rpm 注意rpm区分大小写 查询已安装的以mysql开头的包 rpm  -qa mysql* 查询已安装的mysql 包 rpm -qa|grep mysql rpm的方法有时候也所有已安装的包 ...

  5. grep使用

    grep常用的使用方法 grep –rns “match_content”filename 查看匹配内容的行 find /path –name “*.h” –o –name “*.cpp” | xar ...

  6. 聊一聊ES5数组(Array)新增的那些方法

    一.前言 ES5中新增的一些处理数组(Array)的方法, 对于用JavaScript处理数据非常有用.我总结了一下,给这些方法分了类,大体如下: 2个索引方法:indexOf() 和 lastInd ...

  7. shell脚本中 杀死可能成为僵尸进程的方法

    交互式 Bash Shell 获取进程 pid 在已知进程名(name)的前提下,交互式 Shell 获取进程 pid 有很多种方法,典型的通过 grep 获取 pid 的方法为(这里添加 -v gr ...

  8. linux批量替换文件内容3种方法(perl,sed,shell)

    方法1:perl   这两天在构建一个应用的使用用到了maven,由于project很大,足足有700多个 pom.xml文件,更郁闷的是在很多pom.xml文件里都单独指定了资源库的url,我需要把 ...

  9. linux杀死进程方法

    方法一: 根据pid ps -aux|grep 你的进程 方法二: 删除pid文件 [root@localhost ~]# /etc/init.d/redis_6380 start /var/run/ ...

随机推荐

  1. DzzOffice共享文件夹、共享目录设置

    dzzoffice中共享目录的设置,是通过机构部门建立的. 首先打开机构用户管理.建立需要的机构和部门.这里机构和部门可以理解为共享目录的名称.也可以根据自己需要起名,并不一定是机构和部门的名字. 而 ...

  2. 回调函数与DOM事件

    原文:http://dean.edwards.name/weblog/2009/03/callbacks-vs-events/ 先看如下代码: document.addEventListener(&q ...

  3. RSS阅读器&BT sync

    ①RSS阅读器? 答:RSS阅读器是一种软件或是说一个程序,这种软件可以自由读取RSS和Atom两种规范格式的文档,且这种读取RSS和Atom文档的软件有多个版本,由不同的人或公司开发,有着不同的名字 ...

  4. iOS 获取通讯录权限的时机

    建议将获取通讯录权限的代码放到 -(void)viewDidAppear:(BOOL)animated 或 -(void)viewWillAppear:(BOOL)animated 假如放在 view ...

  5. dom 优酷得弹出

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  6. eCryptfs文件系统测试

    650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" ...

  7. jquery属性选择器中|value和^value的区别

    jquery的属性选择中有两个比较混淆:一个是[attribute^value], 另一个是[attribute|value]. 先看解释: [attribute^value]:选取属性的值以valu ...

  8. 第二百二十四天 how can I 坚持

    实物商品兑换,有点小难搞,其实也没什么难的,也就那些东西,不过好像这就是我设计实现的,干起来挺来劲的. 供暖了,挺暖和的,哈哈. 小米耳机(炫彩版)到了.感觉挺好的. 还在纠结到底要买哪种颜色的羽绒服 ...

  9. vim切换buffer

    [vim切换buffer] 命令 ls 可查看当前已打开的buffer 命令 b num 可切换buffer (num为buffer list中的编号) 其它命令: :bn -- buffer列表中下 ...

  10. HDU 5776 sum (前缀和)

    题意:给定 n 个数,和 m,问你是不是存在连续的数和是m的倍数. 析:考虑前缀和,如果有两个前缀和取模m相等,那么就是相等的,一定要注意,如果取模为0,就是真的,不要忘记了,我当时就没记得.... ...