分类:
2008-06-14 22:18:09
1、使用一系列圆点来指示进度
--------后台循环------------
#!/bin/bash
while true
do
echo -e ".\c"
sleep 3
done &
BG_PID=$!
./test.sh
kill -9 $BG_PID
-----------后台函数---------
#!/bin/bash
dots()
{
while true
do
echo -e ".\c"
sleep 3
done
}
#########################################
########## Begin of Main ################
#########################################
dots &
BG_PID=$!
./test.sh
kill -9 $BG_PID
2、使用一条旋转线来指示进度
#!/bin/bash
rotate()
{
INTERVAL = 1 # Sleep time between "twirls"
TCOUNT = "0" # For each TCOUNT the line twirls one increment
while : # Loop forever ...until this function is killed
do
TCOUNT = $(($TCOUNT + 1)) # Increment the TCOUNT
case $TCOUNT in
"1") echo -e '-' "\b\c"
sleep $INTERVAL
;;
"2") echo -e '\\' "\b\c"
sleep $INTERVAL
;;
"3") echo -e "|\b\c"
sleep $INTERVAL
;;
"4") echo -e "/\b\c"
sleep $INTERVAL
;;
* ) TCOUNT="0" ;; # Reset the TCOUNT to "0",zero
esac
done
} # End of Function rotate
#########################################
########## Begin of Main ################
#########################################
rotate &
ROTATE_PID=$!
./test.sh
kill -9 $ROTATE_PID
# cleanup...
echo -e "\b\b "
# End of Example