[英]How do I enter a new line/move to the next line without executing command while in a shell or bash if the command has more than 1 line?
so i'm trying to follow a tutorial on creating an Azure VM and the entire tutorial is from the CLI.所以我正在尝试按照有关创建 Azure VM 的教程进行操作,整个教程来自 CLI。 It is specifically using bash.
它专门使用bash。 I know next to nothing about using CLI so it is pretty intimdating.
我对使用 CLI 几乎一无所知,所以这很吓人。 Anyways all the commands look like this in the tutorial:
无论如何,教程中的所有命令都如下所示:
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
But when I try to make a new line and go to that new line to enter in the argument/parameter it keeps trying to execute the command and i cant execute anything since obviously what im typing in is missing parameters:但是,当我尝试创建一个新行并将 go 插入到该新行以输入参数/参数时,它一直在尝试执行命令并且我无法执行任何操作,因为显然我输入的是缺少参数:
az vm create \ --resource-group ShahVMAzureUB \ --name ShahVM \ --imageUbuntuLTS \ --admin-username shahjacob \ --generate-ssh-keysaz vm create
: error: the following arguments are required: --name/-n, --resource-group/-g
Quoteth the bash man page引用bash手册页
If a
\<newline>
pair appears, and the backslash is not itself quoted, the\<newline>
is treated as a line continuation (that is, it is removed from the input stream and effectively ignored).如果出现了
\<newline>
对,并且反斜杠本身没有被引用,则\<newline>
被视为续行(也就是说,它从输入 stream 中删除并被有效地忽略)。
So, you literally need a newline (press ENTER ) after you type the \
to tell the shell you want to enter more parameters but on a separate line.因此,在您键入
\
告诉 shell 您想要输入更多参数但在单独的行上之后,您实际上需要一个换行符(按ENTER )。
Generally this is used for print (or even Stackoverflow answers) so you don't have one mega-line that's hard to grok.通常,这用于打印(甚至 Stackoverflow 答案),因此您没有难以理解的巨型行。 If you want it all on one line, remove the
\
between the parameters.如果您希望全部放在一行上,请删除参数之间的
\
。
To expand on SiegeX's answer (since I don't have enough rep to comment...)扩展 SiegeX 的答案(因为我没有足够的代表发表评论......)
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
is functionally equivalent to在功能上等同于
az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
For printing the ENTER in cmd we have to use the echo.为了在 cmd 中打印 ENTER,我们必须使用回显。 command instead of echo "\n" or echo '\n'
命令而不是echo "\n" 或 echo '\n'
Use backtick -(key to the left of q ~ (tilde) and
)使用反引号
-(key to the left of q ~ (tilde) and
and not the '- Apostrophe or single quote.而不是 '- 撇号或单引号。
Just need to use a backtick ` instead of the \
Your code should look like this:
az vm create `
--resource-group myResourceGroup `
--name myVM `
--image UbuntuLTS `
--admin-username azureuser `
--generate-ssh-keys
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.