【问题标题】:How to print a value from output如何从输出中打印一个值
【发布时间】:2015-11-01 14:18:19
【问题描述】:

我想知道如何打印一个值而不是整个输出,例如:ping google.com -t

输出 - 来自 xxx.xxx.xxx.xxx 的回复:byte=32 time=35 TTL=52

而我想要:仅“time=35”或仅数字 - “35” 如果你知道如何帮助我,请帮助我:D 谢谢P。

【问题讨论】:

    标签: file batch-file cmd output


    【解决方案1】:

    从命令行

    for /f "eol=P skip=2 tokens=5 delims= " %# in ('ping google.com -t -n 10') do @if "%#" neq "=" @if  "%#" neq "in" @echo %#
    

    来自批处理文件:

    for /f "eol=P skip=2 tokens=5 delims= " %%# in ('ping google.com -t -n 10') do @if "%%#" neq "=" @if  "%%#" neq "in" @echo %%#
    

    如果您没有设置-n 10,您将不得不等到for /f 缓冲区已满。

    【讨论】:

      猜你喜欢
      • 2014-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-12
      • 2020-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多