paperlined.org
apps > terminals > control_characters
document updated 13 years ago, on Jun 7, 2011

Sometimes, when a long-running program is going, you want it to display some interim results, but erase those interim results once it has more conclusive results. Here are the ANSI codes for doing that:

Erase line, go back to start of line

\r — move cursor to beginning of line

<esc>[K — erase to end of line

Erase screen, go to top-left of screen

<esc>[H — move cursor to top-left of screen

<esc>[J — erase to end of screen

See also