Keith Pinson
Keith Pinson

Reputation: 7995

What is the Bash Escape Character "\c"?

What is the name and function 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?

Upvotes: 17

Views: 29618

Answers (5)

Al a
Al a

Reputation: 9

"\c" means produce no further output.

Upvotes: -1

Rian Sanderson
Rian Sanderson

Reputation: 6712

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

Upvotes: 0

Andrew Clark
Andrew Clark

Reputation: 208655

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

Upvotes: 12

paxdiablo
paxdiablo

Reputation: 882426

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.

Upvotes: 16

Russ Clarke
Russ Clarke

Reputation: 17909

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

Upvotes: 4

Related Questions