Grep命令主要用于从文件中查找指定的字符串。

首先建一个demo_file:

$ cat demo_file

THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.

this line is the 1st lower case line in this file.

This Line Has All Its First Character Of The Word With Upper Case.

Two lines above this line is empty.

And this is the last line.

例01:从单个文件中查找指定的字符串

$ grep "this" demo_file

this line is the 1st lower case line in this file.

Two lines above this line is empty.

例02:从多个文件中查找指定的字符串

$ cp demo_file demo_file1

$ grep "this" demo_*

demo_file:this line is the 1st lower case line in this file.

demo_file:Two lines above this line is empty.

demo_file:And this is the last line.

demo_file1:this line is the 1st lower case line in this file.

demo_file1:Two lines above this line is empty.

demo_file1:And this is the last line.

例03:忽略大小写使用 grep -i

$ grep -i "the" demo_file

THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.

this line is the 1st lower case line in this file.

This Line Has All Its First Character Of The Word With Upper Case.

And this is the last line.

例04:

例05:

例06:

例07:

例08:

例09:

例10:

例11:

例12:

例13:

例14:

例15:

原文:http://blog.csdn.net/jerry_1126/article/details/22760653

linux grep 例子,Linux中Grep常用的15个例子相关推荐

  1. linux中Grep常用的15个例子,Linux中Grep惯用的15个例子

    Linux中Grep常用的15个例子 Grep命令主要用于从文件中查找指定的字符串. 首先建一个demo_file: $ cat demo_file THIS LINE IS THE 1ST UPPE ...

  2. Linux目录和文件中的常用命令(二)

    2019独角兽企业重金招聘Python工程师标准>>> 一 相对路径和绝对路径 1.绝对路径:从根开始 2.相对路径:从当前目录开始 3.cd:change directory更改目 ...

  3. linux从前往后读取文件夹图片名称,Linux目录和文件中的常用命令(三)

    摘要 2.10 环境变量PATH2.11 cp命令2.12 mv命令2.13 文档查看cat/more/less/head/tail 一 环境变量PATH 1.基本的环境变量 基本的环境变量有5个,分 ...

  4. java 泛型例子_java中的泛型的一些常见例子

    /** * @author Rollen-Holt 使用泛型 */ class hello { hello(){ } public T getName(){ return name; } public ...

  5. 如何查看linux的资源,Linux系统资源查看(示例代码)

    以下Linux系统资源查看命令中,较常用的为vmstat 与 lsof vmstat [刷新延时 刷新次数] 1 ucm@ucm-Aspire-TC-606:~$ vmstat 1 5 2 procs ...

  6. 每天学习一个Android中的常用框架——0.目录

    文章目录 1.前言 2.环境 3.目录 3.1 持久化 3.1.1 Litepal 3.1.2 GreenDao 3.1.3 Realm 3.1.4 DBFlow 3.2 网络传输 3.2.1 OkH ...

  7. linux grep命令例子,Linux中grep命令的12个实践例子

    grep是每个Linux发行版都预装的一个强有力的文件模式搜索工具.无论何种原因,如果你的系统没有预装它的话,你可以很容易的通过系统的包管理器来安装它(Debian/Ubuntu系中的apt-get和 ...

  8. linux中grep的例子,Linux下grep命令使用实例

    那么你知道grep命令参数.如何使用grep命令去搜索某个文件中的内容呢.grep 命令递归查找.使用grep去匹配某一个单词么?接下来是小编为大家收集的Linux下grep命令使用实例,欢迎大家阅读 ...

  9. Linux中grep命令 常用选项

    grep的规则表达式: ^: 锚定行的开始 如:^grep匹配所有以grep开头的行. $: 锚定行的结束 如:grep$匹配所有以grep结尾的行. . : 匹配一个非换行符的字符 如:gr.p匹配 ...

最新文章

  1. 进击webpack 4 (基础篇一)
  2. web服务器 字体.svg/.woff/.woff2 404错误 解决方案
  3. 理解分布式系统中的缓存架构(上)
  4. paho.mqtt.embedded-c-master c语言版本架构
  5. 数据结构——最小生成树之prime算法(与最短路径之迪杰斯特拉算法很像)
  6. 从0到1 | 0基础/转行如何用3个月搞定机器学习
  7. 河南大学计算机与信息工程学院张磊,张磊-食品与生物工程学院
  8. URL请求到Action的映射规则
  9. mysql服务没有权限开机不会自启动_计算机服务项里没有MySQL服务,无法设置开机自启动或者关闭自启动,的解决办法...
  10. USB移动硬盘使用中的怪现象
  11. Abseil之Prefer Factory Functions to Initializer Methods
  12. Forms Authentication With Absolute Return URLs
  13. MATLAB 显示输出数据的三种方式
  14. JAVA验证码存在哪里了_java实现验证码功能
  15. 美国第二位CTO Todd Park将离职
  16. 【C语言刷题】汉诺塔问题
  17. 搭建京东客京推推CMS2.0导购网站部署教程,新手教程带视频
  18. 2022-2028全球与中国健康资讯交换(HIE)市场现状及未来发展趋势
  19. Android TV开发(—)开始电视应用
  20. Workflow:Workflow 百科

热门文章

  1. Web前端开发人员和设计师必读文章推荐【系列九】
  2. 那么辛苦努力的工作,却换来了一身的不是
  3. SharePoint 2007 SDK 有了1.1版本
  4. python 中 sorted() 和 list.sort() 的用法
  5. 游戏UI框架设计(三) : 窗体的层级管理
  6. Android中图表AChartEngine学习使用与例子
  7. 希捷硬盘读取固件区数据
  8. java 回滚异常_回滚事务并关闭抛出异常的连接
  9. opengl地球贴纹理_一文看懂材质/纹理 Material, Texture, Shading, Shader 的区别
  10. ajax php计数,jQuery+PHP+Ajax动态数字统计展示实例