ping 命令 带时间显示 批处理实现

来源:百度知道 编辑:UC知道 时间:2024/05/05 09:58:21
能否用批处理来实现这样的现实

Pinging 10.111.23.1 with 32 bytes of data:

[color=red]2005-09-09 00:00:00 [/color]Reply from 10.111.23.1 : bytes=32 time=2ms TTL=255
[color=red]2005-09-09 00:00:01 [/color]Reply from 10.111.23.1 : bytes=32 time=2ms TTL=255
[color=red]2005-09-09 00:00:02 [/color]Reply from 10.111.23.1 : bytes=32 time=1ms TTL=255

ping的结果是不能这样分列显示的。要么全部为红色。

如果说是文本替换倒是可以。以上文本为a.txt,批处理代码:

@echo off&
cd .>op.txt
for /f "delims=" %%i in ('type a.txt^|findstr /n ".*"') do (
set var=%%i
setlocal enabledelayedexpansion
set var=!var:2005=[color:red]2005!
set var=!var:Reply=[/color]Reply!
echo.!var:~2!
endlocal
)>>op.txt

start op.txt
exit