Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If I type ' (single quote, next to the <enter> button) in the terminal and then press enter it drops to a > prompt. What exactly is this, what's it used for, and what type of commands can I enter here?

I can <Ctrl-C> out of it but that's all I got.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

A terminal does not only accept one-line code. Actually, you can write code (as bash scripting is a programming language) in multiple lines.

For example, if you write:

while true; do <enter>

it will show exactly the same > that showed to your case, as well. It lets you input more commands. Now, if you type in:

echo "Cake is a lie" <enter>
sleep 1              <enter>
done                 <enter>

it will start running your code (which, in this occasion it is simply a while loop that will output a string every 1 second). This allows you to build up small programs without having to write them in one-line code, like this:

while true; do echo "Cake is a lie"; sleep 1; done

which, in this case it isn't such a problem, but it could be, in other occasions (with more code to be written).

So, it is generally used for writing multiple lines of code. In your occasion, the shell recognizes that you don't have an even number of ' inside your code, and this could not work in any case (the same applies for "). So, it let's you write more code in order to complete what you've left.

For example, if you give as command:

echo "Cake is a <enter>

then it will let you continue. And indeed, you can:

lie"            <enter>

It will normally output:

Cake is a
lie
share|improve this answer
    
I see, so instead of giving me an error message, its giving me a chance to finish the command intelligibly. Is there a name for this "mode?" –  Insperatus Aug 23 '12 at 0:45
2  
I don't think that it has a special name, it is usually referred as 'secondary prompt' –  hakermania Aug 23 '12 at 1:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.