[英]How to write a multiline “for” loop in the interactive PowerShell window?
I Googled a lot and someone said ` (backtick) can be used for line continuation but it does not work for me. 我google了很多,有人说`(反引号)可以用于续行,但它对我不起作用。 I tried following but both would not work. 我试过跟随,但两个都行不通。
PS C:\> foreach ($i in 1,2) { echo $i; }
1
2
PS C:\> foreach ($i in 1,2) {
>> echo $i;
>> }
>> <== It's still waiting for input. Killed with Ctrl-C.
PS C:\> foreach ($i in 1,2) { `
>> echo $i; `
>> }
>> <== It's still waiting for input. Killed with Ctrl-C.
PS C:\>
You don't need to use backticks (or i didnt have to) 你不需要使用反引号(或者我不需要)
but you do need to press enter a second time. 但你确实需要再次按回车键。
PS C:\> foreach ($i in 1,2) { echo $i; }
1
2
PS C:\> foreach ($i in 1,2) {
>> echo $i;
>> }
>> <== Press enter again here.
1
2
PS C:\>
I presume this then lets the interpreter know that command has finished and allows it to execute. 我假设这使得解释器知道命令已经完成并允许它执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.