开发者

What is the Bash Escape Character "\c"?

What is the name and funct开发者_如何学Goion of the \c escape character in Bash? What is its numeric value? I have seen that \cx is a control character, but what about plain \c? It seems that:

echo -e "Hello World\c"

and

echo -en "Hello World"

are equivalent. However, Python doesn't use it as an escape character, and it is missing from all of the lists of escape characters I found. Is this a Bash-specific behavior?


That's actually specific to some versions of echo (I'm pretty sure that \c came from SysV while the -n version was a BSD-ism).

It simply means don't output the trailing newline.


See the echo man page or the section on echo in the Bash Builtins section of the Bash manual:

echo interprets the following escape sequences:

...
\c
     suppress further output


It's the 'End of Text' control character; it informs the Shell that the end of text has been reached.

Not entirely sure that it's relevant any more, but I could be wrong.

here's the doc:

http://en.wikipedia.org/wiki/ASCII#ASCII_control_characters

and:

http://en.wikipedia.org/wiki/End-of-text_character


Can you update your question with a little more context on how the \c is being used?

You can use \c to escape control characters that you may, say write to a file, or pipe as input to another command.

This will write to the terminal the text "some command" followed by binary ctrl-d (ascii 0x4):

echo some control string $'\cd' 

See full list of escape characters from the bash man page: http://linux.die.net/man/1/bash


"\c" means produce no further output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜