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?
pv Command You can use the “pv” command for copying a single file as it provides statistics related to the progress and speed. In the following case, “pv” will output the “inputfile” to “stdout”, which is then redirected to the “outputfile” using the “>”operator.
While it doesn't display speed, when copying multiple files, the -v option to the cp command will provide you with progress info.
You can use pv
but the other way.
for ... # outer loop
do
...
echo -n X
done | pv -s $(wc -l 'your_file_list') - >/dev/null
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With