Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need help identifying what this escape sequences represents. I see this sequence is autogenerating on my server's console, but I'm not sure what is the reason for that.

Escape sequence: ^[[[D

I've checked this chart of escape sequences as reference: http://ascii-table.com/ansi-escape-sequences-vt-100.php , but haven't found anything matching.

share|improve this question
    
When do you see these characters being printed out (when a prompt is shown, when a specific application is run, randomly, etc)? Also can you confirm there are 3 [ characters, not 2? –  Patrick Jan 6 at 0:13
    
When a prompt is shown. It's on a specific server, specific system - Cisco Unified Communication manager which is based on RHEL distribution. I can confirm it's 3 '[' character, not 2 of them. I was able to interpret ^[[D sequence :) Thanks for your questions –  Pavel Jan 6 at 3:28

2 Answers 2

up vote 2 down vote accepted

NOTE: This is as I understand things, so it might be a bit off!

The characters ^[ typically signifies the Escape key itself. That's a Control (^) + a open square bracket ([).

excerpt from Escape characters - ASCII escape character

The ASCII "escape" character (octal: \033, hexadecimal: \x1B, or ^[, or, in decimal, 27) is used in many output devices to start a series of characters called a control sequence or escape sequence. Typically, the escape character was sent first in such a sequence to alert the device that the following characters were to be interpreted as a control sequence rather than as plain characters, then one or more characters would follow to specify some detailed action, after which the device would go back to interpreting characters normally. For example, the sequence of ^[, followed by the printable characters [2;10H, would cause a DEC VT102 terminal to move its cursor to the 10th cell of the 2nd line of the screen. This was later developed to ANSI escape codes covered by the ANSI X3.64 standard. The escape character also starts each command sequence in the Hewlett Packard Printer Command Language.

On systems where you're using UTF-8 this escape sequence is actually 2 characters, so it's now ^[ followed by an additional [.

excerpt from ANSI escape code - Sequence Elements

There is a single-character CSI (155/0x9B/0233) as well. The ESC+[ two-character sequence is more often used than the single-character alternative, for details see C0 and C1 control codes. Only the two-character sequence is recognized by devices that support just ASCII (7-bit bytes) or devices that support 8-bit bytes but use the 0x80–0x9F control character range for other purposes. On terminals that use UTF-8 encoding, both forms take 2 bytes (CSI in UTF-8 is 0xC2, 0x9B)[discuss] but the ESC+[ sequence is clearer.

Knowing the above 2 pieces of information this would make your escape sequence Esc+[+D which works out to be, big surprise, the backspace character.

excerpt from ANSI Escape sequences

Esc[ValueD     Cursor Backward: Moves the cursor back by the specified 
               number of columns without changing lines. If the cursor is 
               already in the leftmost column, ANSI.SYS ignores this 
               sequence.

References

share|improve this answer
    
Thank you! Now I see. It was weird for me because I didn't know about ^[[ is a UTF-8 escape sequence. –  Pavel Jan 6 at 3:26
    
I found out how to generate the sequence on console screen. Pressing "cursor left" give us the sequence. –  Pavel Jan 6 at 21:28
    
@Pavel - so the cursor backwards at the end of my answer is correct, and now we know how it's getting generated. That key is probably mapped to send the "cursor backward" sequence. The mapping can happen in a number of places, so it might not be worth investigating further. It could be a set through stty or setterm among several other places. –  slm Jan 6 at 21:40
    
Yes, you right. Thank you for your help! –  Pavel Jan 8 at 22:17
    
@Pavel - please mark this answer as accepted if you feel it resovled your issue. This will let others know that your issue's been resolved so they won't attempt to continue with assisting any further. –  slm Jan 8 at 22:53

This sounds like a bad copy paste into a shell profile script.

As @slm indicated, ' ^[ + [ ' is the usual escape sequence, but you're saying you have '^[ + [ + ['. When I look through my terminal emulator's escape codes, I don't see any codes which are ESC followed by 2 brackets.

Since an ESC is a non-printable character, it is often represented in text editors as ^[. I'm guessing someone was editing a profile script which had this escape code, and tried to copy/paste it onto another system. But they copied the visual representation of ESC (^[) instead of the ESC itself.
However this would result in just seeing ^[[D, not ^[[[D. For this, maybe the copy/paste was done by typing it instead, and it's a typo.

In any case, to fix this, you'll need to find the profile script which has this and fix it. If using bash, try the following:

fgrep -r '[[[' /etc/bashrc /etc/bashrc.d /etc/bash_profile /etc/profile /etc/profile.d ~/.profile ~/.bashrc ~/.bash_profile

Once you've found it, it's easy to fix. In the vi editor, just delete the ^[[ characters and in insert mode do Ctrl + v then ESC. This will insert a literal ESC character.

share|improve this answer
    
Hi Patrick, Thank you for your opinion. I have several screenshots with such symbols on it. It wasn't a copy/paste error. And I can reproduce this symbol now. For that I just press on "cursor left" button to get a ^[[[D sequence. –  Pavel Jan 6 at 21:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.