shell进度展示案例

#! /bin/bash
b='' 
for ((i=0;$i<=100;i+=2))  
do  
    printf "progress:[%-50s]%d%%\r" $b $i  
    sleep 0.1  
    b=#$b  
done  
echo




i=0 
while [ $i -lt 20 ]  
do  
       ((i++))  
       echo -ne "=>\033[s"  
       echo -ne "\033[40;50H"$((i*5*100/100))%"\033[u\033[1D"  
   usleep 50000  
done  
echo 


COUNTER=0 
_R=0 
_C=`tput cols`  
_PROCEC=`tput cols`  
tput cup $_C $_R  
printf "["  
while [ $COUNTER -lt 100 ]  
do  
    COUNTER=`expr $COUNTER + 1`  
    sleep 0.1  
    printf "=>"  
    _R=`expr $_R + 1`  
    _C=`expr $_C + 1`  
    tput cup $_PROCEC 101  
    printf "]%d%%" $COUNTER  
    tput cup $_C $_R  
done  
printf "\n" 




i=0 
while [ $i -lt 50 ]  
do  
       ((i++))  
        for j in '-' '\\' '|' '/'  
        do  
       echo -ne "$j\033[s"  
       echo -ne "\033[40;50H"$((i*5*100/100))%"\033[u\033[1D"  
   usleep 50000  
done  
done  
echo


#!/bin/bash 
#Description: A shell script to copy parameter1 to parameter2 and Display a progress bar 
#Author:Jacob 
#Version:0.1 beta 
 
# Read the parameter for copy,$1 is source dir and $2 is destination dir 
dir=$1/* 
des=$2 
# Test the destination dirctory whether exists 
[ -d $des ] && echo "Dir Exist" && exit 1 
# Create the destination dirctory 
mkdir $des 
# Set counter, it will auto increase to the number of source file 
i=0 
# Count the number of source file 
n=`echo $1/* |wc -w` 
 
for file in `echo $dir` 
  do 
# Calculate progress 
percent=$((100*(++i)/n)) 
cat <<EOF 
XXX 
$percent 
Copying file $file ... 
XXX 
EOF 
/bin/cp -r $file $des &>/dev/null 
  done | dialog --title "Copy" --gauge "files" 6 70 
clear 
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值