user10085367
user10085367

Reputation:

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. It is specifically using bash. I know next to nothing about using CLI so it is pretty intimdating. 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:

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

Upvotes: 12

Views: 41726

Answers (4)

Fast prep
Fast prep

Reputation: 29

Use backtick -(key to the left of q ~ (tilde) and )

and not the '- Apostrophe or single quote.

Upvotes: 0

shashikant
shashikant

Reputation: 55

For printing the ENTER in cmd we have to use the echo. command instead of echo "\n" or echo '\n'

Upvotes: -1

Brendan Thorpe
Brendan Thorpe

Reputation: 88

To expand on SiegeX's answer (since I don't have enough rep to comment...)

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

Upvotes: 2

SiegeX
SiegeX

Reputation: 140477

Quoteth the man page

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).

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.

Generally this is used for print (or even Stackoverflow answers) so you don't have one mega-line that's hard to grok. If you want it all on one line, remove the \ between the parameters.

Upvotes: 13

Related Questions