入门命令13-字符串查找增强:findstr

http://www.cnblogs.com/doupip/archive/2011/12/23/2299210.html

 

 

在文件中寻找字符串。

FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/F:file]
        [/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
        strings [[drive:][path]filename[ ...]]

  /B        在一行的开始配对模式。 beginning of a line
  /E        在一行的结尾配对模式。 end of a line
  /L        按字使用搜索字符串。 literally
  /R        将搜索字符串作为一般表达式使用。regular expressions
  /S        在当前目录和所有子目录中搜索 current directory and all subdirectories
             匹配文件。
  /I         指定搜索不分大小写。ignore case-sensitive
  /X        打印完全匹配的行。 exactly
  /V        只打印不包含匹配的行。invert-match即反转匹配
  /N        在匹配的每行前打印行数。 Prints the line number
  /M        如果文件含有匹配项,只打印其文件名。a file contains a match.
  /O        在每个匹配行前打印字符偏移量。character offset
  /P        忽略有不可打印字符的文件。non-printable characters.
  /OFF[LINE] 不跳过带有脱机属性集的文件。offline attribute set.
  /A:attr   指定有十六进位数字的颜色属性。请见 "color /?" Specifies color attribute with two hex digits.
  /F:file   从指定文件读文件列表 (/ 代表控制台)。Reads file list from the specified file
  /C:string 使用指定字符串作为文字搜索字符串。 specified string as a literal search string(charactor)
  /G:file   从指定的文件获得搜索字符串。 (/ 代表控制台)。Gets search strings from the specified file
  /D:dir    查找以分号为分隔符的目录列表 list of directories 
  strings   要查找的文字。
  [drive:][path]filename
            指定要查找的文件。

除非参数有 /C 前缀,请使用空格隔开搜索字符串。
例如: 'FINDSTR "hello there" x.y' 在文件 x.y 中寻找 "hello" 或
"there" 。  'FINDSTR /C:"hello there" x.y' 文件 x.y  寻找
"hello there"。

一般表达式的快速参考:
  .        通配符: 任何字符
  *        重复: 以前字符或类别出现零或零以上次数
  ^        行位置: 行的开始
  $        行位置: 行的终点
  [class]  字符类别: 任何在字符集中的字符
  [^class] 补字符类别: 任何不在字符集中的字符
  [x-y]    范围: 在指定范围内的任何字符
  \x       Escape: 元字符 x 的文字用法
  \<xyz    字位置: 字的开始
  xyz\>    字位置: 字的结束

有关 FINDSTR 常见表达法的详细情况,请见联机命令参考。

  

posted @ 2015-09-24 21:57  IamThat  阅读(702)  评论(0编辑  收藏  举报