对于声明>代币发行 [英] for statement > tokens issue
问题描述
我想在运行命令的我自己的命令提示符下创建命令.
I want to create a command in my own command prompt that runs a command.
因此,我设置了一个样本变量.在这里:
So I set a sample variable. Here it is:
set m=sample -gtc new -args sample
所以我尝试使用for
来获取-gtc
之后和-args
之后的命令.
So I tried using for
in order to get the command after -gtc
and after -args
.
这是我的for
命令:
for /f "tokens=3,5" %%e in ("%m%") do echo %%e
命令已响应.但是它只像tokens=3
那样响应,这意味着该命令仅回显-gtc
之后的那个,而不包括-args
.
The command responded. But it only responded like tokens=3
meaning the command only echo-ed the one after -gtc
not including the -args
.
我遵循的方式 https://ss64.com/nt/for_cmd.html 说.
tokens = 2,4,6将导致处理每一行的第二,第四和第六项
以同样的方式在我的命令中会发生什么呢?就是这样.
So the same way what will happen in my command right? It's just like this.
tokens = 3,5将导致处理每行上的第三和第五项
推荐答案
要对多个令牌使用FOR /F
,则将提取的令牌存储在随后的FOR/F变量中.
To use FOR /F
with multiple tokens, the fetched tokens are stores in subsequently FOR /F variables.
在您的情况下for /f "tokens=3,5" %%e in ("%m%") do echo %%e
位置3的第一个令牌存储在%%e
中,位置5的第二个令牌存储在%%f
In your case for /f "tokens=3,5" %%e in ("%m%") do echo %%e
The first token at position 3 is stored in %%e
and the second token at position 5 is stored in %%f
这篇关于对于声明>代币发行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!