比如我netstat -an|find "3389">>终端.txt
会在"终端.txt"里显示一行:
TCP 192.168.0.1:2386 192.168.0.110:3389 ESTABLISHED
我现在只想让它显示192.168.0.110这个ip地址,要怎么做?
多谢各位了,我是新手,希望能提供个思路,不胜感激.作者: bagpipe 时间: 2006-5-23 09:07 for /f "tokens=1,2,3,4 delims=: " %%a in ('"netstat -na|findstr "8000""') do @echo %%d>>终端.txt作者: fan927 时间: 2006-5-23 11:31 非常感谢楼上的回复,麻烦您再解释一下吗?作者: fan927 时间: 2006-5-23 13:25 如果从ip.txt中只读取"Reply from 127.0.0.X: bytes=32 time<1ms TTL=64"行中的ip部分,应该怎么写?
ip.txt内容如下:
Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=64
Pinging 127.0.0.3 with 32 bytes of data:
Reply from 127.0.0.3: bytes=32 time<1ms TTL=64
Pinging 127.0.0.4 with 32 bytes of data:
Reply from 127.0.0.4: bytes=32 time<1ms TTL=64
Ping statistics for 127.0.0.1:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
Control-C
我用for /f " eol=P tokens=3" %%i in (ip.txt) do echo %%i
只能忽略掉P开头的行,我只需要R开头的行,需要什么选项?谢谢了
[ Last edited by fan927 on 2006-5-23 at 13:31 ]作者: bagpipe 时间: 2006-5-23 13:59 不好意思,刚刚看到
看下面:
@echo off
setlocal enabledelayedexpansion
for /f "eol=P tokens=3 delims=: " %%a in ('findstr /c:"Reply" ip.txt') do set ii=!ii! %%a
echo %ii%作者: fan927 时间: 2006-5-23 14:40 bagpipe
太强了,我初学批处理,以后还请多多指教