Board logo

标题: [求助]for findstr 查找文本文件中特定的行 [打印本页]

作者: joyoustar     时间: 2008-8-1 12:08    标题: [求助]for findstr 查找文本文件中特定的行

1.比如有一文本文件123.txt内容如下:
1
22
333
4444
55555
44444
33333
22222
1
12
123
1234
12345
2.我需要用for语句先忽略前面n行(比如4行),然后在解析的字符串中用find或者findstr查找有数字3的行并显示出来。最后效果如下:
33333
123
1234
12345
3.请问用for,find或findstr等语句怎样写(尽量不要用临时文件)?谢谢指教!

[ Last edited by joyoustar on 2008-8-1 at 12:10 PM ]
作者: pooronce     时间: 2008-8-1 12:54
for /f "skip=4 delims=" %i in (123.txt) do @echo %i|findstr "3"
作者: bat-zw     时间: 2008-8-1 13:11
more +4 123.txt|findstr "3"
作者: joyoustar     时间: 2008-8-1 15:14


  Quote:
Originally posted by pooronce at 2008-8-1 12:54 PM:
for /f "skip=4 delims=" %i in (123.txt) do @echo %i|findstr "3"

谢谢!但不知怎的,文本文件中如果有“:\”,用findstr ":\"查找就会出错,也即
for /f "skip=4 delims=" %i in (123.txt) do @echo %%i|findstr ":\" 会出错,不会出现查询结果,好象和“\”符号有关,用find就可以。还有就是查询效率不高。
作者: joyoustar     时间: 2008-8-2 16:57


  Quote:
Originally posted by bat-zw at 2008-8-1 01:11 PM:
more +4 123.txt|findstr "3"

用more命令能否显示截止到某行n(不是最后的行)或者显示到某个符号所在的行为止?