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:
\r — move cursor to beginning of line
<esc>[K — erase to end of line
<esc>[H — move cursor to top-left of screen
<esc>[J — erase to end of screen