本帖最后由 yaua 于 2011-8-7 14:29 编辑
http://www.bathome.net/viewthread.php?from=notice&tid=12715
源代码在这个帖子中,但试验一个txt,发现导出的行不完整
比如原始txt为- (005321) 8/6/2011 14:07:48 PM - (not logged in) (125.43.38.191)> 331 Password required for anonymous
- (005321) 8/6/2011 14:07:51 PM - (not logged in) (125.43.38.191)> PASS *******
- (005321) 8/6/2011 14:07:51 PM - (not logged in) (125.43.38.191)> 530 Login or password incorrect!
- (005321) 8/6/2011 14:07:51 PM - (not logged in) (125.43.38.191)> QUIT
- (005321) 8/6/2011 14:07:51 PM - (not logged in) (125.43.38.191)> 221 Goodbye
- (005321) 8/6/2011 14:07:51 PM - (not logged in) (125.43.38.191)> disconnected.
- (005322) 8/6/2011 14:08:08 PM - (not logged in) (125.43.38.191)> Connected, sending welcome message...
- (005322) 8/6/2011 14:08:08 PM - (not logged in) (125.43.38.191)> 220-FileZilla Server version 0.9.39 beta
- (005322) 8/6/2011 14:08:08 PM - (not logged in) (125.43.38.191)> 220-written by Tim Kosse (Tim.Kosse@gmx.de)
- (005322) 8/6/2011 14:08:08 PM - (not logged in) (125.43.38.191)> 220 Please visit http://sourceforge.net/projects/filezilla/
- (005322) 8/6/2011 14:08:09 PM - (not logged in) (125.43.38.191)> USER anonymous
- (005322) 8/6/2011 14:08:09 PM - (not logged in) (125.43.38.191)> 331 Password required for anonymous
- (005322) 8/6/2011 14:08:09 PM - (not logged in) (125.43.38.191)> PASS *******
- (005322) 8/6/2011 14:08:09 PM - (not logged in) (125.43.38.191)> 421 Temporarily banned for too many failed login attempts
- (005322) 8/6/2011 14:08:09 PM - (not logged in) (125.43.38.191)> disconnected.
复制代码 使用代码为-
- @echo off
- set "str=220"
- (for /f "tokens=1* delims=:" %%a in ('findstr "%str%" "FileZilla Server.log"') do (
- echo,%%b
- ))>111.log
复制代码 导出的内容为-
- 08:08 PM - (not logged in) (125.43.38.191)> 220-FileZilla Server version 0.9.39 beta
- 08:08 PM - (not logged in) (125.43.38.191)> 220-written by Tim Kosse (Tim.Kosse@gmx.de)
- 08:08 PM - (not logged in) (125.43.38.191)> 220 Please visit http://sourceforge.net/projects/filezilla/
复制代码 似乎前面的日期并没有完整导出,是何原因
还有个问题,要是查找的字符不知一个,比如 220 或 not 两个关键词,又该如何修改代码 |