FIND 在一个或多个文件中搜索一个文本字符串
C:\Users\Administrator>find /?
在文件中搜索字符串。
FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]
/V 显示所有未包含指定字符串的行。
/C 仅显示包含字符串的行数。
/N 显示行号。
/I 搜索字符串时忽略大小写。
/OFF[LINE] 不要跳过具有脱机属性集的文件。
"string" 指定要搜索的文本字符串。
[drive:][path]filename
指定要搜索的文件。
如果没有指定路径,FIND 将搜索在提示符处键入
的文本或者由另一命令产生的文本。(1)搜索文件,输出包含 “you” 字符串的所有行,如下:
C:\Users\Administrator\Desktop\tmp>find "you" a.txt
---------- A.TXT
But then, i never met you
I like you as a sweet chant
I miss you as a floating boat
I want you as a throbbing heart
Maybe now, i find you(2)搜索文件,输出包含 “you” 字符串的行数,如下:
C:\Users\Administrator\Desktop\tmp>find /C "you" a.txt
---------- A.TXT: 5上面输出可知,有5行包含“you”字符串。
(3)搜索文件,输出包含 “you” 字符串的所有行,并且显示行号,如下:
C:\Users\Administrator\Desktop\tmp>find /N "you" a.txt
---------- A.TXT
[4]But then, i never met you
[5]I like you as a sweet chant
[6]I miss you as a floating boat
[7]I want you as a throbbing heart
[8]Maybe now, i find you(4)搜索文件,忽略大小写,如下:
C:\Users\Administrator\Desktop\tmp>find /N /I "YOU" a.txt
---------- A.TXT
[4]But then, i never met you
[5]I like you as a sweet chant
[6]I miss you as a floating boat
[7]I want you as a throbbing heart
[8]Maybe now, i find you