This character can be generated alone by the ESC key found on most
keyboards, or by typing the left bracket character while holding down
the CONTROL key (often shown as
But it's also generated by many
of the special keys on your keyboard.
For example, an UP ARROW key
might generate an escape sequence like
When the terminal sees
this sequence of characters, it knows to move the cursor up one line.
The special escape sequences used by your terminal are stored in the terminal's, which allows programs to respond appropriately to all of the special keys on the keyboard. Programs themselves issue escape sequences to do such things as move around the screen, highlight text, and so on.
However, there are cases where it's useful to issue escape sequences manually - or in an alias or shell script that you write. For example, you canor .
Most of our examples use escape sequences for the common DEC VT100 series of terminals (which are also recognized by almost all terminal emulation programs).
How do you find out what escape sequences your terminal uses? After all, it is quite hardware-specific. If you have a terminal manual, they should be listed there. Otherwise, you can, and with the help of the manual page, or a book such as O'Reilly & Associates' termcap & terminfo, decipher the obscure language used there. Or, use a program like ; it will find those sequences for you.
To actually type an escape sequence into a file, use your editor's "quote next character command" (41.9.) before pressing the ESC key. To use an escape character in an alias, try the technique shown in article
Don't be confused if you see an escape sequence that looks like this:
Some terminals use a real left bracket at the start of their escape
sequence; it will follow the escape character itself (represented as
Even though they look the same on the screen, they are really
different characters (CTRL-
[ or ESC is different from
[, just like
CTRL-c is different from
|5.7 What termcap and terminfo Do and Don't Control||5.9 Setting Your Erase, Kill, and Interrupt Characters|