简体   繁体   English

如果在一行中运行,如何分隔命令(FOR…DO)

[英]How to separate the command (FOR … DO) if run in one line

For example: FOR /F "delims==" %G IN ('SET') DO @echo %G & pause 例如: FOR /F "delims==" %G IN ('SET') DO @echo %G & pause

After this command, a pause is set every time after a line is output. 使用此命令后,每次输出一行后都会设置一个暂停。

But I need to pause after the output of all the lines (without batch file, only one command line). 但是我需要在所有行的输出之后暂停(没有批处理文件,只有一个命令行)。

The commands after for ... in (...) do are all considered as being placed in the loop body. for ... in (...) do之后的命令都被视为放置在循环体内。 To change that behaviour you have to use parentheses, like this: 要更改该行为,您必须使用括号,如下所示:

(for /F "delims==" %G in ('SET') do @echo %G) & pause

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM