How to replace console output vertically in bash
I am using Bash (cygwin), and I would like to implement something like a progress indicator that spans vertical lines. It replaces the console output and does not append to it. It needs to look like an animation.
So this output appears over time:
--- --- ---
*-- --- ---
*** *-- ---
The trick is to span vertical lines.
It is easy with echo if you do not span vertical lines. I can use \b to move backwards a space and overwrite previous characters:
echo -n -e "\b"
But how do you move up a line and overwrite previous lines.
You use ANSI escape-sequence to move the cursor:
\033[NA - cursor up N lines \033[NB - cursor down N lines \033[NC - cursor right N steps \033[ND - cursor left N steps
$ echo -e '\033[8Chello' hello