-   Linux - Newbie (
-   -   Multiple lines in terminal (

seabass341 06-08-2009 01:59 PM

Multiple lines in terminal
How do you type multiple lines from the main terminal? I knew at one point but seem to have forgotten. When doing this a "greater than" sign appears and the terminal allows you to enter in multiple lines as if you were in a text editor. As so:


for i in 1 2 3
>echo $i

Anyone know how to do this? Help is much appreciated.

acid_kewpie 06-08-2009 02:10 PM

you just type it... happens automatically.

i92guboj 06-08-2009 02:12 PM

The '>' is a secondary prompt indicating that the command you just type is unterminated and need additional input. You don't need to do anything special. When you type a "for" statement and press enter it will keep asking for input until you enter the "done" part, that is, unless you enter it all in a single line like "for i in <list>; do foo; done"

seabass341 06-08-2009 02:13 PM

happens automatically?

David the H. 06-08-2009 02:15 PM

End the line with a backslash '\'. The backslash is the escape character, which in this case means that you are escaping the invisible newline character that follows it. This forces the shell to temporarily ignore the enter command, allowing you to span multiple lines.

You can also enclose a string in single quotes to make it span a newline. The single, or 'hard' quote does the same thing as the backslash for every character it encloses. It escapes any special meanings they may have.

Edit: sorry, the "soft" double quotes will do it also. Double quotes are called soft because they will allow a few characters to be interpreted, like $ for variable names. And as mentioned above, certain commands will also automatically allow continuation on extra lines when they are still "incomplete".

You can read more about shell quoting and escaping here (though it's not specific to bash, the concepts are mostly the same):

spdp 06-08-2009 10:14 PM

This is so difficult....:-(

pixellany 06-08-2009 10:29 PM


Originally Posted by spdp (Post 3567510)
This is so difficult....:-(

No, it's not.....

Welcome to LQ---but please don't hijack threads like this---especially with statements or questions that have no substance

All times are GMT -5. The time now is 05:11 PM.