Home > Mobile >  Go to a specific line in terminal using Python
Go to a specific line in terminal using Python

Time:12-12

I had a Python code that print 33 line in terminal, so I want to jump back to line 11 and rewrite all text in that line, how can i do that?

CodePudding user response:

You will have to use a package like curses to take control of the terminal. That's what apps like vi use to do their drawing. That lets you draw strings at specific row and column position.

CodePudding user response:

This is why it's useful to have some familiarity with less.

You could use 11g to jump to the beginning of the line or 11G to jump to the end of the line.

Or from the command line, you could use less 11 filename.py or less 11 -N filename.py if you want to see the line numbers. You can also display a specific line of the file at a specific line of the terminal by using less 11 -j 10 filename.py.

  • Related