我有这个批处理脚本,通过运行4个不同的文本文件(IMSI1.txt IMSI2.txt等),在其中search-imsi并输出它旁边的值。
@echo off setlocal EnableDelayedExpansion set N=4 for /L %%r in (1,1,%N%) do ( for /F "delims=" %%a in ('findstr /C:"-imsi" IMSI%%r.txt') do set line=%%a for /F %%a in ("!line:*-imsi=!") do echo %%a>> out & echo %%a> N%%r.txt )
例
Hello this is the text file asdasd -imsi 367 asdasd -imsi 888
产量
888
期望的输出
367 888
我怎样才能修复输出?
你几乎在那里:
@echo off setlocal EnableDelayedExpansion set N=1 for /L %%r in (1,1,%N%) do ( for /F "delims=" %%a in ('findstr /C:"-imsi" IMSI%%r.txt') do ( set line=%%a for /F %%a in ("!line:*-imsi=!") do echo %%a>> out & echo %%a> N%%r.txt ) )