Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-08-2009, 02:59 PM   #1
LQ Newbie
Registered: Jun 2009
Posts: 3

Rep: Reputation: 0
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.
Old 06-08-2009, 03:10 PM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
you just type it... happens automatically.
Old 06-08-2009, 03:12 PM   #3
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
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"
Old 06-08-2009, 03:13 PM   #4
LQ Newbie
Registered: Jun 2009
Posts: 3

Original Poster
Rep: Reputation: 0
happens automatically?


Last edited by seabass341; 06-08-2009 at 03:15 PM.
Old 06-08-2009, 03:15 PM   #5
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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):

Last edited by David the H.; 06-08-2009 at 03:20 PM.
Old 06-08-2009, 11:14 PM   #6
LQ Newbie
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
This is so difficult....:-(
Old 06-08-2009, 11:29 PM   #7
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Originally Posted by spdp View Post
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


help, terminal

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
New lines in terminal mg92865 Linux - Newbie 10 10-30-2012 12:56 AM
New lines in gnome-terminal overlapping old lines instead of scrolling crontab Linux - Software 2 04-17-2009 11:08 AM
Rewriting multiple lines in C++ terminal application bandwidthjunkie Programming 4 04-06-2007 10:34 PM
AWK/SED Multiple pattern matching over multiple lines issue GigerMalmensteen Programming 15 12-03-2006 06:08 PM
weird lines on X window terminal - I'm worried... towsonu2003 Linux - Hardware 8 09-22-2005 04:34 PM

All times are GMT -5. The time now is 04:34 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration