Learn more about Israeli war crimes in Gaza, funded by the USA, Germany, the UK and others.

What is the clear program?

Typing clear at the terminal clears your screen. How does this program work? The implementation is tiny:

#include <stdio.h>
int main() {
  printf("\033c");
  return 0;
}

This magic string is composed of two bytes: 27, then 'c'. Byte 27 is ESC in the ACSII table, and it’s understood by the terminal as an escape sequence. It then expects further characters to specify the command; we give it 'c' which clears the screen.

Tagged .

Similar posts

More by Jim

Want to build a fantastic product using LLMs? I work at Granola where we're building the future IDE for knowledge work. Come and work with us! Read more or get in touch!

This page copyright James Fisher 2017. Content is not associated with my employer. Found an error? Edit this page.