Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there go up line character? (Opposite of \n)

I would like to overwrite something on a line above in a serial console. Is there a character that allows me to move up?

like image 295
Sponge Bob Avatar asked Jul 13 '12 16:07

Sponge Bob


People also ask

What is the opposite of \n in Java?

Java supports Unicode, which has the character "REVERSE LINE FEED" (U+008D). In Java it would be '\u008D' (as a char ) or "\u008D" (as a String ).

How do you go back one line in Python?

You can try to use '\033[1A' to go back one line (substitute 1 with number of lines to jump. It will probably break in some terminals.

How do you get to the upper line in C++?

cout << "\n\n\n\n\n\n\n\n\n\n\xc9\xbb\n\xc8\xbc"<<flush; Sleep(50);


1 Answers

Most terminals understand ANSI escape codes. The relevant codes for this use case:

  • "\033[F" – move cursor to the beginning of the previous line
  • "\033[A" – move cursor up one line

Example (Python):

print("\033[FMy text overwriting the previous line.") 
like image 81
Sven Marnach Avatar answered Sep 17 '22 17:09

Sven Marnach