I sometimes copy-paste paths into the terminal, and often accidentally copy the newline character. For example, I want to find then read the contents of
$ locate foobar.txt /home/sparhawk/Document Directory/foobar.txt
I then select the second line with a triple click. (Oops, it selects the trailing newline too!) Since there is a space in the path, I need to enclose the path in quote marks. Hence type in
$ cat '
and middle-click to paste. This produces
$ cat '/home/sparhawk/Document Directory/foobar.txt >
since I have inserted a newline before closing the
'. At this point, I cannot press backspace to delete the newline. Is there a way to delete this just-typed newline?
At this point I can either
SIGINT with Ctrl+c, or complete the quote with another
'. Let's say I do the latter.
$ cat '/home/sparhawk/Document Directory/foobar.txt > ' cat: /home/sparhawk/Document Directory/foobar.txt : No such file or directory
which makes sense, as I just typed in a path with newline in it. However, at this point, I can press the up arrow, to load the last command. i.e.
$ cat '/home/sparhawk/Document Directory/foobar.txt '
At this point, I can press backspace twice to delete the newline. (N.B. there is no
> in the second from-history example.)