zoukankan      html  css  js  c++  java
  • grep 同时满足多个关键字和满足任意关键字

    grep 同时满足多个关键字和满足任意关键字
    ① grep -E "word1|word2|word3"   file.txt
       满足任意条件(word1、word2和word3之一)将匹配。
    ② grep word1 file.txt | grep word2 |grep word3
       必须同时满足三个条件(word1、word2和word3)才匹配。
     
     
    其实这很好理解,只是我平时没有用多个关键字搜索过,一下子有点蒙,平时遇到也是先度娘,哈哈哈哈哈,哎
     
    grep keyword filename  |  grep keyword2
    前一段多搜索结果  通过管道到另一边 在查询很有关键字keyword2到
     
    倒是满足任何一个关键字到, -E命令要记一下
     

    -E, --extended-regexp

                 Interpret pattern as an extended regular expression (i.e. force

                 grep to behave as egrep).

     

         -e pattern, --regexp=pattern

                 Specify a pattern used during the search of the input: an input

                 line is selected if it matches any of the specified patterns.

                 This option is most useful when multiple -e options are used to

                 specify multiple patterns, or when a pattern begins with a dash

                 (`-').

     

         --exclude

                 If specified, it excludes files matching the given filename pat-

                 tern from the search.  Note that --exclude patterns take priority

                 over --include patterns, and if no --include pattern is speci-

                 fied, all files are searched that are not excluded.  Patterns are

                 matched to the full path specified, not only to the filename com-

                 ponent.

     

         --exclude-dir

                 If -R is specified, it excludes directories matching the given

                 filename pattern from the search.  Note that --exclude-dir pat-

                 terns take priority over --include-dir patterns, and if no

                 --include-dir pattern is specified, all directories are searched

                 that are not excluded.

     

         -F, --fixed-strings

                 Interpret pattern as a set of fixed strings (i.e. force grep to

                 behave as fgrep).

     

         -f file, --file=file

                 Read one or more newline separated patterns from file.  Empty

                 pattern lines match every input line.  Newlines are not consid-

                 ered part of a pattern.  If file is empty, nothing is matched.

  • 相关阅读:
    VS中注释的使用
    VS2010中:error C2471: 无法更新程序数据库
    VS2010 MFC中在对话框上添加工具栏以及工具栏提示信息并改变图标支持256色
    CToolBar与CToolBarCtrl以及CStatusBar 与CStatusBarCtrl的区别
    error C2664: “wcscpy”: 不能将参数 1 从“LPSTR”转换为“wchar_t *”
    VS2010 MFC中的Picture控件显示图像
    VS2010 MFC中屏蔽ESC和ENTER键关闭对话框的方法
    MFC中CImageList(图形列表控件)、CTreeCtrl(树形列表控件)的简单用法
    窗口类、窗口类对象与窗口 三者之间关系——孙鑫<VC++深入详解>
    VS2010 MFC中改变static字体颜色、大小、背景颜色(自定义类),及手动关联变量的方法
  • 原文地址:https://www.cnblogs.com/qianjinyan/p/9085305.html
Copyright © 2011-2022 走看看