Shell脚本100%进度条显示

#!\bin\bash
drawper ()
{
_per=`expr $1 \* 100 / $2`
case `expr $_per / 4 % 4` in
0) _char="|" ;;
1) _char="/" ;;
2) _char="-" ;;
3) _char="\\" ;;
esac
printf "\r$_char $_per%%"
if [ $1 -eq $2 ];then
printf "\n"
fi
}
 
i=1
while [ $i -le 100 ]
do
drawper $i 100
i=`expr $i + 1`
done

Leave a Comment.