I'm trying to parse a .txt file using batch script, line by line, untill I find "arg =" string and then get the following number. To put it into context, I'm trying to parse this gdb.txt file
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]
I've come up with these few lines of batch script:
@echo off
for /f delims^=^ eol^= %%A in (gdb.txt) Do (
echo %%A
findstr /c:"arg =" %%A>nul 2>nul
echo %errorlevel%
)
I would like the script to recognize the line with "arg =" so I can read 0 afterwards. However this script seems not to be able to recognize "arg =" and always prints %errorlevel% as 1. What am I missing here?