Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的小 cmd 脚本有问题。
set i=1 set tmp=0 for /F "tokens=*" %%A in (test.txt) do ( set /A i+=1 echo %i%=%%A ) echo %i%
我的问题是为什么循环中的行echo %i%=%%A给出这个输出
echo %i%=%%A
1=text one 1=text two 1=text three 4
取而代之的是
2=text one 3=text two 4=text three 4
感谢您的任何回答。
好的,现在可以使用
set i=1 set tmp=0 setlocal enabledelayedexpansion for /F "tokens=*" %%A in (test.txt) do ( set /A i+=1 echo !i!=%%A ) echo %i%