What is the literal for cntrl+c (like ^[ is a lite

2019-09-25 15:46发布

What is the literal for cntrl+c - kill process (like ^[ is a literal escape). I need to code this literal in here document of one of shell script to get exit the control.

SOme one please help me.. :(

标签: linux shell
2条回答
Root(大扎)
2楼-- · 2019-09-25 16:46

I guess you mean the ^C character sequence?

查看更多
在下西门庆
3楼-- · 2019-09-25 16:47

The ASCII code for ctrl-C is 3; it is often represented as ^C but this is just a human representation consisting of the two characters ^ and C.

In legacy character sets, the control characters often had a graphical representation, so on an old IBM PC (CP437) you would see a heart glyph ♥ if you looked at a file containing this character. In Unicode, it simply has no representation at all although some fonts contain a small box with the characters "ETX" in it (the "end of text" semantics from ASCII are purely historical, however). In my browser, <<>> is simply the empty string, but yours might show something else between the angle brackets.

Putting a ctrl-C in a here document will nevertheless not generate a signal; the signal is generated by the interactive terminal driver when it receives this character (and the character can be reconfigured easily; man stty). When the shell parses a here document, the terminal driver is not involved at all.

To send a signal from a script, use the kill command.

查看更多
登录 后发表回答