O'Reilly logo

The Linux Command Line by William E. Shotts Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Moving the Cursor

Escape codes can be used to position the cursor. This is commonly used to provide a clock or some other kind of information at a different location on the screen, such as an upper corner, each time the prompt is drawn. Table 13-4 lists the escape codes that position the cursor.

Table 13-4. Cursor Movement Escape Sequences

Escape Code

Action

\033[l;cH

Move the cursor to line l and column c.

\033[nA

Move the cursor up n lines.

\033[nB

Move the cursor down n lines.

\033[nC

Move the cursor forward n characters.

\033[nD

Move the cursor backward n characters.

\033[2J

Clear the screen and move the cursor to the upper-left corner (line 0, column 0).

\033[K

Clear from the cursor position to the end of the current line.

\033[s

Store the current cursor position. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required