Windows: How to specify multiline command on comma

2019-01-06 12:54发布

how do we extend a command to next line?

basically whats the windows alternative for linux's

ls -l \
/usr/

here we use backslash to extend command on next line

whats the equivalent for windows?

3条回答
时光不老,我们不散
2楼-- · 2019-01-06 13:13

After trying almost every key on my keyboard:

C:\Users\Tim>cd ^
Mehr? Desktop

C:\Users\Tim\Desktop>

So it seems to be the ^ key.

查看更多
一夜七次
3楼-- · 2019-01-06 13:16

In the Windows Command Prompt the ^ is used to escape the next character on the command line. (Like \ is used in strings.) Characters that need to be used in the command line as they are should have a ^ prefixed to them, hence that's why it works for the newline.

For reference the characters that need escaping (if specified as command arguments and not within quotes) are: &|()

So the equivalent of your linux example would be (the More? being a prompt):

C:\> dir ^
More? C:\Windows
查看更多
劳资没心,怎么记你
4楼-- · 2019-01-06 13:21

The caret character works, however the next line should not start with double quotes. e.g. this will not work:

C:\ ^
"SampleText" ..

Start next line without double quotes (not a valid example, just to illustrate)

查看更多
登录 后发表回答