I want to show a progress bar during a bash operation in a specific format something similar to the following:
[###########](40%)
after update it should become
[###############](50%)
and then similarly reach upto 100%
Is there any way to achieve this
I wrote the following bash program but i don't know how to show the percentage in this on same line:
#!/bin/bash
{
echo -n "["
for ((i = 0 ; i <= 100 ; i+=6)); do
sleep 0.05
echo -n "###"
done
echo -n "]"
echo
}
Let's assume that a certain number of operations are being performed in a loop and after the completion of each operation, I want to report some progress. I don't want to install pv
or any other utilities that does not come with default Ubuntu 12.04
installation.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…