Sample Header Ad - 728x90

Best way to create table-like CLI display in Bash?

2 votes
3 answers
13437 views
I'm working on a Bash script for massive USB flash memory testing (using f3 under the hood). I need to display a table-like interface with multiple columns and cells. Currently I'm using printf with and it looks like this: enter image description here I have a separate function running for each drive that write out text to a log file. These log files are parsed to display the information to the user. As you can see some rows have offsets that shouldn't be there but I can't get rid of them It doesn't seem to be caused by long strings being printed. I don't know what's this. Another problems I have is the refresh time and the need to manually clear and redraw the whole screen at times, due to ocasional stderr messages appearing there from grep or cat when some files don't read properly. I'm currently doing a partial rewrite of this script and I what I could od better in regard to printing out the data on the screen. I thought about looking into ncurses but that seems like a bit too complicated thing and would probably make things way to complex for me to maintain. I wonder if there is a way for me to dump the echo or print commands to a text file and then execute that all at once to basically have a text "backbuffer" so my refresh can be more consistent and faster? I would also want to be able to listen for user's keystrokes and react to that in the background but that's not a priority. Maybe there's a better way to do this kind of thing in Bash, that I don't know of?
Asked by unfa (1825 rep)
Nov 29, 2017, 11:43 AM
Last activity: Apr 13, 2020, 08:01 PM