进度条——shell脚本实现

时间:2016-06-17 00:59:50   收藏:0   阅读:856

进度条在以后开发,测试,运维中,可实现自动化检查项目的更新、运行等情况,大大加快工作效率。

1.代码实现

  1 #!/bin/bash
  2 function proc()
  3 {
  4     count=0
  5     bar=""
  6     lable=("|" "/" "-" "\\")
  7     while [ $count -le 100 ]
  8     do
  9         let index=count%4
 10         printf "[\033[1m\033[1;34m%-101s\033[0m] [%d%%] [%c]\r" "$bar" "$count" "${lable[$index]}"
 11         bar=${bar}‘=‘
 12         ((count++))
 13         sleep 0.05
 14     done
 15     printf "\n"
 16 }
 17 proc

2.输出结果:

技术分享

本文出自 “sunshine225” 博客,请务必保留此出处http://10707460.blog.51cto.com/10697460/1790053

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!