bat 文件中简单引用的问题
我正在尝试执行包含循环的bat 文件。 执行循环时,文件执行将中止。
我修改了一些命令以了解错误是什么,似乎我无法将简单的引用放入循环中。
/f "tokens=1,2 delims==" %%i IN ("version=X.Z.W") do set VERSION=%%j -> success
/f "tokens=1,2 delims==" %%i IN ('version=X.Z.W') do set VERSION=%%j -> failure
这很烦人,因为 version=XZW
应该由 findstr /B /c:"%var%=" ..\..\file.properties
返回,
我在不同的平台上进行了测试桌面,这个问题只出现在我的电脑上。 不知道有什么设置需要修改吗?
直接在命令提示符中键入命令时遇到问题。
非常感谢您的帮助。
I am trying to execute bat file containing a loop.
When executing a loop, the file execution is aborted.
I modified a little the command to understand what is the error and it seems I cannot put simple quote into the loop.
/f "tokens=1,2 delims==" %%i IN ("version=X.Z.W") do set VERSION=%%j -> success
/f "tokens=1,2 delims==" %%i IN ('version=X.Z.W') do set VERSION=%%j -> failure
It is annoying as version=X.Z.W
should be returned by findstr /B /c:"%var%=" ..\..\file.properties
I tested on different desk, and this issue occurs only on my computer.
Do you know if there is any settings to modify?
I have the issue when typing the command directly into a command prompt.
Thanks a lot for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您直接在命令提示符中输入上述内容,则会失败,因为您使用了
%%
而不是%
。 Windows CMD 不会像处理批处理文件那样读取%%
。CMD 读取
'
与"
的方式不同。'
被读取为命令,其中"
为作为文字字符串读取。If you are typing the above directly into a command prompt, it will fail because you have used
%%
instead of%
. Windows CMD doesn't read%%
as it does processing a batch file.And the
'
as opposed to"
are read differently by CMD.'
is read as a command where"
is read as a literal string.