Tuesday, February 27, 2007

Fake Progress Bar in shell


Just to illustrate the use of "until" loop in BASH, here is a small script to generate a fake progress bar.

#!/bin/sh
clear
echo "Installation in Progress" [`basename $0`]
count=0
until [ $count -eq 10 ]
do
echo -n "###"
sleep 1
count=`expr $count + 1`
done
echo -n "[100%]"
echo

$ ./fakeprogress.sh
Installation in Progress [fakeprogress.sh]
##############################[100%]

2 comments:

hamen said...

Fake, but effective!
Thanks

MAREMOTO said...

Unfortunately I'm not as good as you, and I am beginner in the art of shell script, that would help me on a question: would implement a bar processro a command like?

pg_dump-h localhost postgres | bzip2-c / backup/backup_database.sql.bz2

Thank you for your patience and comprehension.

© Jadu Saikia www.UNIXCL.com