Board logo

标题: [求助]字符串匹配自动统计问题,请高人指点,跪谢!! [打印本页]

作者: manfen     时间: 2008-1-2 18:48    标题: [求助]字符串匹配自动统计问题,请高人指点,跪谢!!

编写一批处理,自动统计IP地址显示次数
原文件如下ip.txt:
[5] Tue 20Nov07 09:38:53 - (000238) Connected to 192.168.1.101 (Local address 192.168.200)
[5] Tue 20Nov07 09:38:54 - (000239) Connected to 192.168.1.101 (Local address 192.168.200)
[5] Mon 19Nov07 19:04:51 - (000055) Connected to 192.168.1.1 (Local address 192.168.200)
[5] Mon 19Nov07 19:04:53 - (000056) Connected to 192.168.1.1 (Local address 192.168.200)
[5] Mon 19Nov07 19:04:55 - (000057) Connected to 192.168.1.1 (Local address 192.168.200)
[5] Mon 19Nov07 19:04:59 - (000058) Connected to 192.168.1.1 (Local address 192.168.200)
编写批处理:for /f "tokens=9" %i in (ip.txt) do findstr %i last.txt || echo %i >>last.txt
由于192.168.1.1字符串在192.168.1.101中匹配,因此统计结果始终为:192.168.1.101,192.168.1.1始终不能自动统计,请高手指点迷津!!
跪谢!!!
作者: lxmxn     时间: 2008-1-2 19:30
findstr /c:"\<%i\>" last.txt
作者: nipo     时间: 2008-4-27 20:58
经典!高手就是高手。