Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I confirm a multi line input in the commandline?

Tags:

bash

I have something like this

command \
second line of command \
...
...

How do I confirm so it executes?

like image 269
Blub Avatar asked Nov 02 '11 00:11

Blub


People also ask

How do I run a multi line command in terminal?

Using a Backslash. The backslash (\) is an escape character that instructs the shell not to interpret the next character. If the next character is a newline, the shell will read the statement as not having reached its end. This allows a statement to span multiple lines.

What is the command for multiline?

Access the MLINE command to draw multilines.

How do you comment multiple lines in shell script?

In Shell or Bash shell, we can comment on multiple lines using << and name of comment. we start a comment block with << and name anything to the block and wherever we want to stop the comment, we will simply type the name of the comment.

How do you echo multiple lines?

To add multiple lines to a file with echo, use the -e option and separate each line with \n. When you use the -e option, it tells echo to evaluate backslash characters such as \n for new line. If you cat the file, you will realize that each entry is added on a new line immediately after the existing content.


1 Answers

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

like image 96
John Gordon Avatar answered Oct 07 '22 12:10

John Gordon