0

I do this a lot:

user@machine: $ ls'
>
# Me: Argh! I did it again!
>'

: No such file or directory

Basically, I finish typing a command, and hit ' by accident when trying to hit enter, and end up with an un-closed single-quote. I can't get back up to the previously line to delete it, so end up just running the command with a syntax error.

Is there a way to recover this and fix my command?

  • Related: http://unix.stackexchange.com/questions/232912/what-is-the-effect-of-a-lone-backtick-at-the-end-of-a-command-line – Kusalananda Apr 10 '17 at 14:03

1 Answers1

2

You could hit CtrlC instead to avoid running the command, then the up arrow and BackSpace to remove the offending quote.

Stephen Kitt
  • 434,908
  • I thought ctrl + c was only for interrupting a command after it was executing. I guess I erroneously assumed it would log me out of my shell or something if nothing was running. – Scribblemacher Apr 10 '17 at 14:17
  • @Scribblemacher Technically, it is interrupting an executing command: the shell. The shell, however, catches the signal and, instead of exiting, simply cancels the current input and displays the next prompt. – chepner Apr 10 '17 at 21:06