zoukankan      html  css  js  c++  java
  • linux命令---查找文件中的内容

    linux命令---查找文件中的内容  

     

    [yang@localhost ~]$ cat 1.txt |egrep '123456789|second'-------匹配123456789或者second的行

    first line:123456789012345678901234567890123456789012345678901234567890

    second line:one two three four five six seven eight nine ten

     

    [yang@localhost ~]$ cat 1.txt |egrep 'two' |egrep 'one'----匹配two 且匹配one的行

    second line:one two three four five six seven eight nine ten

     

    [yang@localhost ~]$ cat 1.txt |grep 'two' |grep 'one'----匹配two 且匹配one的行

    second line:one two three four five six seven eight nine ten

     

     

    [yang@localhost ~]$ grep -o 123456789 1.txt |wc -l  -----123456789出现的次数

    6

    [yang@localhost ~]$ cat 1.txt |grep -o 123456789 |wc -l    -----123456789出现的次数

    6

    [yang@localhost ~]$ more 1.txt |grep -o 123456789 |wc -l  -----123456789出现的次数

    6

    [yang@localhost ~]$

     

     

     

    [yang@localhost ~]$ more 1.txt |grep -o 'one..........two' |wc -l   -----------'one..........two'出现的次数,中间10个点表示隔了10个字

    1

    [yang@localhost ~]$ cat -n 1.txt |grep 'one..........two'      ----------匹配'one..........two'的行,中间10个点表示隔了10个字

        53     one1234567890two

    [yang@localhost ~]$

  • 相关阅读:
    Node.js 笔记03
    Node.js 笔记02
    Node.js 笔记01
    源代码管理工具-git
    ES6笔记01
    07_查找、软链接、打包压缩、软件安装
    06_系统信息相关命令
    oracle序列中cache和nocache
    PL/SQL规范、块、过程、函数、包、触发器
    对Xcode菜单选项的详细探索(干货)
  • 原文地址:https://www.cnblogs.com/qmfsun/p/4550458.html
Copyright © 2011-2022 走看看