标题: [文本处理] [已解决]用bat读取log文件的指定格式 [打印本页]
作者: ANSL 时间: 2022-5-17 18:15 标题: [已解决]用bat读取log文件的指定格式
本帖最后由 ANSL 于 2022-5-18 08:28 编辑
用bat读取1.log获取[]里的内容并去掉name:
name:后面是个空格
1.log内容:
Microsoft(R) Windows NT Kernel Debugger
Version 3.51
(C) 1991-1995 Microsoft Corp.
Symbol search path is: *** Invalid *** : Verify _NT_SYMBOL_PATH setting
KD: waiting to reconnect...
imagehlp.dll has a version mismatch with the debugger
debugger version: 3.5.3, built: Tue Apr 16 02:23:44 1996 [name: c:\users\administrator\desktop\debug\i386kd.exe]
imagehlp version: 4.0.5, built: Thu Jan 01 08:00:00 1970 [name: c:\windows\system32\imagehlp.dll]
kdext version: 3.5.3, built: Fri Apr 19 05:06:21 1996 [name: c:\users\administrator\desktop\debug\kdextx86.dll]
作者: yakeyun 时间: 2022-5-17 18:39
回复 1# ANSL - @echo off&setlocal enabledelayedexpansion
- (
- for /f "tokens=1-7 delims=^:" %%a in ('type "1.log" ^|find /i "name: "') do (
- set date1=%%f:%%g
- set "date1=!date1: =!"
- for /f "tokens=1 delims=]" %%i in ('echo,!date1!') do (
- echo %%i
- )
- )
- ) >2.log
复制代码
作者: ngd 时间: 2022-5-17 19:08
- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=2 delims=[]" %%a in ('type "1.log" ^| find /i "name: "') do (
- set str=%%a
- set str=!str:name: =!
- echo !str!>>2.log
- )
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |