在文件中搜索字符串。
FIND [/V] [/C] [/N]
[[drive:][path]filename[ ...]] [/I] [/OFF[LINE]] "string"
/V 显示所有未包含指定字符串的行。
/C 仅显示包含字符串的行数。
/N 显示行号。
/I 搜索字符串时忽略大小写。
/OFF[LINE] 不要跳过具有脱机属性集的文件。
"string" 指定要搜索的文字串,
[drive:][path]filename
指定要搜索的文件。
如果没有指定路径,FIND 将搜索键入的或者由另一命令产生的文字。
Find常和type命令结合使用
Type [drive:][path]filename | find "string" [>tmpfile] #挑选包含string的行
Type [drive:][path]filename | find /v "string" #剔除文件中包含string的行
Type [drive:][path]filename | find /c #显示文件行数
以上用法将去除find命令自带的提示语(文件名提示)
例:
@echo off
echo 111 >test.txt
echo 222 >>test.txt
find "111" test.txt
del test.txt
pause
运行显示如下:
---------- TEST.TXT
111
请按任意键继续. . .
例:
@echo off
echo 111 >test.txt
echo 222 >>test.txt
type test.txt|find "111"
del test.txt
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库批处理中的变量+set命令详解++if命令讲解+DOS编程高级技巧(8)在线全文阅读。
相关推荐: