I have made a pretty basic progress bar in BASH like this :-
doned=$1 #amount completed
total=$2 #total amount
doned=`echo $doned $total | awk '{print ($1/$2)}'`
total=`tput cols | awk '{print $1-10}'`
doned=`echo $doned $total | awk '{print int(($1*$2))}'`
echo -n $doned"% [ "
for i in $(seq 1 $doned); do
echo -n "="
done
for i in $(seq $((doned+1)) $total); do
echo -n "-"
done
echo " ]"
This works exactly like I want it to.
This script runs within a loop in another script. I want it to always display at the bottom of the terminal, or any other fixed place.
The loop is somewhat like this:-
for i in 10 20 30 40; do
echo -n "Do you want to continue on to the next step? (y/n): ";
read $yn
if [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]]; then
exit 1; # stop the script
d_3=0;
fi
doned=`some command` ### Get number of completed files
totalss=`some other command` ### Get total number of files
bash ./libraries/prog.sh $doned $totalss
done
So what I want is that the progress bar remain at the bottom even when inputting values, or displaying something. Is there a way to do this, preferably without having to install anything extra? Most of the computers I want to use this script on are either Debian version 8+ or Ubuntu 16+ systems
pv
, ordialog
/whiptail --gauge
?bash
orseq
installed (those are GNU software found by default on GNU systems but few others).tput
is a standard command, buttput cols
is not standard...