LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
LinkBack Search this Thread
Old 06-08-2009, 01:59 PM   #1
seabass341
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:

Code:
for i in 1 2 3
>do
>echo $i
>done
Anyone know how to do this? Help is much appreciated.
 
Old 06-08-2009, 02:10 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,345

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

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
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, 02:13 PM   #4
seabass341
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Original Poster
Rep: Reputation: 0
happens automatically?

Thanks

Last edited by seabass341; 06-08-2009 at 02:15 PM.
 
Old 06-08-2009, 02: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: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
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):
http://www.grymoire.com/Unix/Quote.html

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

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

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Quote:
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
 
  


Reply

Tags
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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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


All times are GMT -5. The time now is 02:53 PM.

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