This question already has an answer here:
- How to add a progress bar to a shell script? 36 answers
I'm using the following script to go through a large list of domains in whois and find the registrar (useful for server/DNS migrations) and it works fine.
However I am wanting to incorporate a progress bar into it just for the sake of convenience. Here's my script, if it can be improved let me know:
#!/bin/bash
for f in `cat /var/www/vhosts/domainlist`
do
if
domain=$f
[ "$domain" ] ;
then
whois $f | grep -i domainregistrar > /dev/null
if
[ $? -le 0 ] ;
then
echo $f >> our_registrar
else
echo $f >> external_registrar
fi
fi
done
echo "Done, check our_registrar file."
I've tried this first: http://moblog.bradleyit.com/2010/02/simple-bash-progress-bar-function.html
And then this but with no luck.
What do you reckon is the easiest way to get a progress bar implemented into that script?
Change the outer loop to:
http://linux.die.net/man/1/pv
Or you can use any other program that provides a progress bar based on how much a file has been read.
Here's a fancy progress bar that you might enjoy...
looks like this:
You can use
pv
but the other way.so you use
echo X
to say when another portion of work is done and this is counted by pv, it's know what the whole job size is due to-s
option.Given that you mentioned in a comment that you're on a debian based system, you could use
whiptail
. When you install a deb package that requires configuration, text-based windows are drawn to ask you stuff; that'swhiptail
.Something like
You could use something like:
from https://gist.github.com/ivanalejandro0/9159989
You can see an usage example in https://github.com/ivanalejandro0/misc/blob/master/shell-scripts/copy-progress.sh
I suggest you to use Xdialog, Kdialog or zenity and it's progress option.