简体   繁体   中英

Single Quote Entry in Bash

I accidentally entered a single single quote in the commandline of my Debian x86_64 laptop. This starts a > prompt. A second single quote ends the prompt, with the message that the command could not be found.

What is happening here? What commands (if any) are expected?

You can add quotes around values to ensure they're treated as strings and not interpreted, eg:

$ echo 'Hello > foo.txt'
Hello > foo.txt

Note that without quotes this would have been a very different command.

Strings can also include newlines:

$ echo 'Hello
> World'
Hello
World

That's all you're seeing there, a line continuation.

$ '
> '
command not found: \n

This simply means you entered a newline character as the one and only thing, so it's being interpreted as a command (eg like echo ), and it's not a defined command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM