【发布时间】:2021-02-24 10:23:17
【问题描述】:
我正在尝试使用批处理脚本逐行解析 .txt 文件,直到找到“arg =”字符串,然后得到以下数字。为了把它放到上下文中,我正在尝试解析这个 gdb.txt 文件
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x00007c2c in ?? ()
Loading section .sec1, size 0x20000 lma 0x0
Start address 0x8560, load size 131072
Transfer rate: 103 KB/sec, 1110 bytes/write.
Command Executed successfully: semihosting enable
Breakpoint 1 at 0x790a: file C:\LMA\ws_new\wam_sdk1886.31.001.1C_ver1\src\sdk\wam\bsp\detail/exit.c, line 21.
Note: automatically using hardware breakpoints for read-only addresses.
Breakpoint 1, exit (arg=0) at C:\LMA\ws_new\wam_sdk1886.31.001.1C_ver1\src\sdk\wam\bsp\detail/exit.c:21
21 volatile std::uint8_t a = 0;
arg = 0
[Inferior 1 (Remote target) detached]
我想出了这几行批处理脚本:
@echo off
for /f delims^=^ eol^= %%A in (gdb.txt) Do (
echo %%A
findstr /c:"arg =" %%A>nul 2>nul
echo %errorlevel%
)
我希望脚本能够识别带有“arg =”的行,以便之后我可以读取 0。 但是,此脚本似乎无法识别“arg =”并始终将 %errorlevel% 打印为 1。 我在这里错过了什么?
【问题讨论】:
标签: batch-file scripting