bash 如何确认命令行中的多行输入?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7974652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I confirm a multi line input in the commandline?
提问by Blub
I have something like this
我有这样的事情
command \
second line of command \
...
...
How do I confirm so it executes?
我如何确认它执行?
回答by John Gordon
The backslash (\) at the end of the line continues the command to the next line. Don't end the last line of the command with a backslash and it will execute the whole command.
行尾的反斜杠 (\) 将命令延续到下一行。不要以反斜杠结束命令的最后一行,它将执行整个命令。
If you have an unclosed quote (" or '), the command also won't complete until you close the quote. Also some uncompleted commands are detected and continue to prompt you for the rest of the command. In bash, simply typing 'if' for example won't complete until the shell sees the terminating 'fi'.
如果您有未关闭的引号(" 或 '),则在关闭引号之前,该命令也不会完成。还会检测到一些未完成的命令并继续提示您输入命令的其余部分。在 bash 中,只需键入 'if ' 例如,在 shell 看到终止的 'fi' 之前不会完成。
回答by Adam Zalcman
The first line not ending with a '\' will execute it.
不以“\”结尾的第一行将执行它。

