On the terminal prompt for OS X I can type in echo $'\ec' and ti will clear the console. I have no idea why this works, though. What is it doing?

I'm guessing this would work on other versions of linux, too. Can someone shed some light?

3 Answers 3


\e is the ESC character (0x1B). This is known as an “escape sequence”.

There is a whole list of them on the Internet for the VT100 or ANSI terminal, which you can look at to understand how they work.

FYI, you can do the same thing with printf "\x1bc\n", or clear the screen completely by omitting that final \n.

  • There are a lot of sources, but the one suggested is particularly poor. Sep 28, 2015 at 9:18

A terminal usually does not have an API per se, so the terminal driver listens for specific sequences of characters being sent to the terminal and takes action based on the sequences received. The ^[c sequence causes the terminal to be cleared, and is just one of many such sequences.


The particular sequence is sent as


(the escape character followed by c). That happens to be the hardware reset function for a VT100. On a real terminal, that would break your connection. Terminal emulators (which you more likely are using) will merely reset the terminal to its default state, incidentally clearing the display. Since they are generally emulating (imitating) the VT100, the suitable place to start reading is the documentation for VT100s:

Regarding the "vtansi" link, that has been noted in an FAQ for several years: How do I get color with VT100?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .