Search code examples
language-agnosticshellterminalpretty-print

How do I move printing position up one line in terminal


I'm already aware of using \b and \r to move back one character and to the beginning on the line respectively. But is there a way, (specifically in python,) to move the cursor position up 1 line? I'm trying to avoid using curses, but if this is the best option then so be it.


Solution

  • The cuu1 capability will give you the sequence you need in order to do so.

    echo -e "aa\n$(tput cuu1)b"