简体   繁体   中英

Why does powershell -c 'write-output "foo bar"' print its output on two lines?

When I invoke powershell with the -c command line parameter and a write-output "foo bar" command, the words are printed on separate lines:

PS> powershell -c 'write-output "foo bar"' 
foo
bar

When I execute the following line, it prints both words on the same line, which is what I expected for the above command as well:

powershell -c 'cmd /c echo foo bar'
foo bar

I don't understand what makes the word printed on separate lines.

As Santiago Squarzon said, this should work in Powershell

PS> powershell -c "write-output 'foo bar'"
foo bar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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