Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In sh (not Bash), how would we abort execution of command when the prompt is in > mode?

For example, when entering a string with quotes only at the beginning, it makes the prompt look like >, without the ability to quit it normally, unless hitting Ctrl + D. Example:

root@MyPC:~# echo "hello
> I am
> (How do I exit of this mode?)

In case that I don't know which character delimits the string (" or ' or simply escaping a newline/spaces with backslash), is there a way to let Bash know that I want to abort the execution of the current command?

share|improve this question
up vote 10 down vote accepted

^C aka Ctrl+C will abort what you're doing and get you back to a normal prompt.

share|improve this answer
A good thing to know in general for interrupting any running command. – orion Mar 5 '14 at 10:09
if it does not work try also crtl + d to stop process and if does not work use ctrl + z to background the running command find it's PID and kill it with kill – Kiwy Mar 5 '14 at 10:54
^D will only work if a process is reading from standard input. ^\ is a good one too (sends a SIGQUIT). – Flup Mar 5 '14 at 11:01
@Kiwy Easier is to run jobs and use kill %x – Bernhard Mar 5 '14 at 12:19
It depends what intr is set to on the tty. If you do stty -a you'll see which control codes are set to do what. – Flup Mar 5 '14 at 15:32

Your Answer


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.