I would like to spruce up the output of a Bash shell script by doing some simple, ncurses-like console displays.
For instance, I would like to show a percentage value increasing as some activity completes. I can do this by outputting each percent value on a new line, for example,
0%
1%
2%
... etc. ...
But I would prefer to have the text update in place (that is, the script only writes one line of output to show the percent, and then the percent value displayed on that line changes). I know I could use a different scripting language and ncurses, but is there a Bash solution that doesn’t incur too much pain. Preferably, I’d like something with wide support across various Unix’es.
Outputting
\rwill return the cursor to the first column so that you can write over the text already in place. If you need more sophisticated motion than that,tputwith the variouscu*capabilities will allow you to move and place the cursor as desired.