Given that two lines have been printed out in the terminal, is it possible to delete both of them so they may be replaced with two new lines?
I know you can use \r to replace 1 line (well, to move the cursor to the start of the line), but is there any way of doing this for the line above?
As an example, I'm running a program for computing the eigenfunctions of the Schrodinger equation and I want to keep an eye on how my variables are changing as it's being run, so I'd like an output like:
Param 1: xxxxxxx
Param 2: xxxxxxx
So I'd have the two parameters on two lines so they can be easily read and they'd be updated on each iteration of the program's matching function.
The cuu1
terminal capability allows you to go up a line. Pass it to tput
in order to read the character sequence from the terminfo/termcap database, and then echo
it twice.
echo -e '123\nabc\n'"$(tput cuu1)$(tput cuu1)"'*\n*'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With