格式化批处理文件 ping 命令的结果
Format result from a batch file ping command
我写了一个 bat 文件,它获取我们所有商店的 IP 地址并对其执行 ping 操作。我想格式化结果,以便 return 只有时间响应。
目前我正在使用类似的东西:
ping -n 1 xx.xxx.xxx.xx | FIND "TTL=" >>output.txt
这只给我一个回显请求响应,这就是我想要的。我只想去掉粗体文本。
来自xx.xxx.xxx.xx的回复:bytes=32 time= 22ms TTL=57
您可以通过 for
循环 运行 结果并使用空格和 =
符号作为分隔符以仅提取时间。
for /F "tokens=7 delims==< " %%A in ('ping -n 1 xx.xxx.xxx.xx ^| find "TTL"') do (
echo %%A>>output.txt
)
我写了一个 bat 文件,它获取我们所有商店的 IP 地址并对其执行 ping 操作。我想格式化结果,以便 return 只有时间响应。
目前我正在使用类似的东西:
ping -n 1 xx.xxx.xxx.xx | FIND "TTL=" >>output.txt
这只给我一个回显请求响应,这就是我想要的。我只想去掉粗体文本。 来自xx.xxx.xxx.xx的回复:bytes=32 time= 22ms TTL=57
您可以通过 for
循环 运行 结果并使用空格和 =
符号作为分隔符以仅提取时间。
for /F "tokens=7 delims==< " %%A in ('ping -n 1 xx.xxx.xxx.xx ^| find "TTL"') do (
echo %%A>>output.txt
)