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.
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.
>
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.
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
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.
In addition to the other answers, you also get the continuation prompt when you type a \
as the last character on a line.
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 beforePS1
is displayed.PS2
: The secondary prompt string. The default value is ‘>
’.
… followed by:
6.3.3 Interactive Shell Behavior
- Bash expands and displays
PS1
before reading the first line of a command, and expands and displaysPS2
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:
\
, which is treated as a line continuation.$()
, ()
, ``
.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.
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