I am using bash on Mac OS X as well as Lubuntu. One of the annoying things about when I make console applications is that
will add a whole (x-number) of lines to the console. And then I rewrite the screen, which is time consuming and inefficient.
Instead I am looking for a way to make my app not create extra lines and rewrite characters that are currently shown. (like the "top" command)
For example, my app needs to make a number in the upper left corner of the console go up as fast as possible.
Example #1: Using clear
#!/bin/bash for i in `seq 1 1000000` do echo $i clear done
This would be great besides that it "flickers", hangs sometimes, wastes console space, and is generally ugly.
Example #2: Using backspace
#!/bin/bash echo -e "\033[8;5;10;t" clear echo -e -n "0" for i in `seq 1 1000000` do echo -e -n "\b\b\b\b\b\b\b$i" done
This one runs like a charm, doesn't create extra lines, and is quick, but it can only be run in small windows.
Example #3: Using the sort of rewriting formula that "top" and "alsamixer" do.
How would I do this example?