Updating the last two lines displayed on the terminal using the shell?
I am trying to create a simple progress bar script that will display a panel as well as the current activity.
With help echo -ne "[||...] Processing ${file_name}\r"
I can display the progress bar like:
[|||||||| ............] Processing file1
However, I expect to output something like this:
File processing1
[|||||||| ............]
Note. Both are separate lines and I want to update them as my progress script.
Is there a way to achieve this?
source to share
The solution suggested by @that another guy suggests that to fill in the differences in $RANDOM
(a non-standard bash -special function that returns 1 to 5 digits).
This can be accomplished using a terminal capability that clears from the cursor position to the end of the line. In both cases, the scripts assume the messages are short enough that line wrapping is not an issue (the OP's question gave an example with this capability):
#!/bin/bash
UP1="$(tput cuu 1)"
EL0="$(tput el)"
while sleep 1
do
date
printf '%s%s\r%s' "$RANDOM" "$EL0" "$UP1"
done
source to share