@echo off
set /p m=请输入要删除的行
setlocal enabledelayedexpansion
del temp.txt 2>nul
for /f "tokens=*" %%i in (1.txt) do (
set /a n+=1
if !n! neq %m% echo %%i>>temp.txt
)
del 1.txt
ren temp.txt 1.txt
pause
结果很完美了,
--------------------------------------------------
2016/08/08 周一
20:03:18.32
Pinging google.com [74.125.130.138] with 32 bytes of data:
Packets: Sent = 100, Received = 100, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 78ms, Maximum = 114ms, Average = 84ms
2016/08/08 周一
20:04:57.80
--------------------------------------------------
--------------------------------------------------
2016/08/08 周一
20:33:26.59
Pinging google.com [74.125.130.101] with 32 bytes of data:
Packets: Sent = 100, Received = 99, Lost = 1 (1% loss),
Approximate round trip times in milli-seconds:
Minimum = 81ms, Maximum = 83ms, Average = 81ms
2016/08/08 周一
20:35:09.60
--------------------------------------------------
处理后的文本:
--------------------------------------------------
Start at
2016/08/08 周一
20:03:18.32
Pinging google.com [74.125.130.138] with 32 bytes of data:
Ping statistics for 74.125.130.138:
Packets: Sent = 100, Received = 100, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 78ms, Maximum = 114ms, Average = 84ms
end at
2016/08/08 周一
20:04:57.80
--------------------------------------------------
待处理的文本:
--------------------------------------------------
Start at
2016/08/08 周一
20:03:18.32
Pinging google.com [74.125.130.138] with 32 bytes of data:
Reply from 74.125.130.101: bytes=32 time=82ms TTL=41
Request timed out.
......
Reply from 74.125.130.101: bytes=32 time=82ms TTL=41
Ping statistics for 74.125.130.138:
Packets: Sent = 100, Received = 100, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 78ms, Maximum = 114ms, Average = 84ms
end at
2016/08/08 周一
20:04:57.80
--------------------------------------------------