Board logo

标题: for 中 delims=( 的括号怎么写? [打印本页]

作者: yq7654     时间: 2011-1-8 19:05    标题: for 中 delims=( 的括号怎么写?

命令:
ping localhost -n 1
得到如下内容:

Pinging asus_z99mseries [127.0.0.1] with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms TTL=64

Ping statistics for 127.0.0.1:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms


现在,我想把 (0% loss) 中括号内的内容提出来,用
for /l "token=2,3 delims=( " %i in ......

SET KH=(
for /l "token=2,3 delims=%kh% " %i in .....
都提示错误:
此时不应有 "token=2,3 delims=( "
作者: Hanyeguxing     时间: 2011-1-8 19:33

@echo off
for /f "tokens=1-6 delims==, " %%a in ('ping localhost -n 1') do if /i "%%a"=="Minimum" echo %%a:%%b %%c:%%d %%e:%%f
pause

作者: yq7654     时间: 2011-1-8 19:48
我的意思是说,下面这一 句

    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),


把    (0% loss)  括号中的内容提出来
for /f  "delims=             后面的"("怎么表示出来
最终的意思是 在FOR 中 ,用括号作为分隔符

[ Last edited by yq7654 on 2011-1-8 at 19:50 ]
作者: Hanyeguxing     时间: 2011-1-8 20:17

@echo off
for /f "tokens=2 delims=()" %%a in ('ping localhost -n 1') do echo %%a
pause

作者: yq7654     时间: 2011-1-11 22:27
三口!