19

Alright, when I run certain commands the wrong way, (misspelled, etc.) The terminal outputs this: > instead of computername:workingfolder username$, and when I type enter it goes like this:

>

>

>

That would be if I pressed enter 3 times.

43

> is the default continuation prompt.That is what you will see if what you entered before had unbalanced quote marks.

As an example, type a single quote on the command line followed by a few enter keys:

$ '
> 
> 
> 

The continuation prompts will occur until you either

  • (a) complete the command with a closing quote mark

    or

  • (b) type Ctrl+D to finish input, at which point the shell will respond with an error message about the unbalanced quotes,

    or

  • (c) type Ctrl+C which will abort the command that you were entering.

How this is useful

Sometime, you may want to enter a string which contains embedded new lines. You can do that as follows:

$ paragraph='first line
> second line
> third line
> end'

Now, when we display that shell variable, you can see that the prompts have disappeared but the newlines are retained:

$ echo "$paragraph"
first line
second line
third line
end
| improve this answer | |
16

That will happen if you have an unclosed quote in your command. That's something like:

$ echo "test here
>
>
...

You can exit that mode by closing the quote (write a " or ', or whatever your open quote is). It could also be a brace-delimited block, a partially-complete for-do or while-do loop, or certain other constructs. You can also press Ctrl-C to cancel this command (then press Up to revise it).

This can sometimes happen without an obvious missing quote when parameter or history expansions occur where you didn't expect them.


The > is your PS2 ("secondary prompt") value. You can change that to something else to remind you what's happened:

PS2="Unclosed >"

in your .bashrc will make it print Unclosed > at the start of each line instead.

| improve this answer | |
7

In addition to the other answers, you also get the continuation prompt when you type a \ as the last character on a line.

| improve this answer | |
  • 5
    (For me, this usually happens by accident, as the backslash is frighteningly close to the Enter key.) – Mr Lister Oct 3 '14 at 6:40
  • Not on my keyboard, it isn't. – TRiG Oct 3 '14 at 15:29
  • @TRiG You mean, you often type # by accident instead of \? Right... – Mr Lister Oct 4 '14 at 13:29
7

The answer lies in this cryptic mention in the Bash Reference Manual:

5.1 Bourne Shell Variables

[...]

  • PS1: The primary prompt string. The default value is ‘\s-\v\$’. See Printing a Prompt, for the complete list of escape sequences that are expanded before PS1 is displayed.
  • PS2: The secondary prompt string. The default value is ‘>’.

followed by:

6.3.3 Interactive Shell Behavior

  1. Bash expands and displays PS1 before reading the first line of a command, and expands and displays PS2 before reading the second and subsequent lines of a multi-line command.

So, the > prompt appears if you press Enter and Bash determines that the command is incomplete. That could be because:

  • The character before the newline is a \, which is treated as a line continuation.
  • You have an incomplete string (mismatched quotes or unterminated here-doc) or some other mismatched delimiters, such as $(), (), ``.
  • You have started a function definition, a for loop, a while loop, or a case.

If you are seeing the secondary prompt due to an unintentional typing error, hit ControlC to return to the primary prompt.

| improve this answer | |
  • You also get the secondary prompt when you're typing into a here-doc. But this is less likely to happen by accident than the others. – Barmar Oct 8 '14 at 19:28
6

The shell waiting for you to complete the command. Maybe there's a unclosed quote somewhere or it thinks you are starting a "for" loop and waits for the user to finish typing

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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