Posted By

ksaver on 08/22/10


Tagged

bar Bash progress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

khajavi


A very simple bash progress bar.


 / Published in: Bash
 

URL: http://identi.ca/ksaver

  1. #!/usr/bin/env bash
  2. # simplepb.sh
  3. # A very simple bash progress bar.
  4. # Still needs a lot of work to become useful.
  5. # ksaver (at identi.ca), Aug 2010.
  6. # License: Public Domain
  7.  
  8. function progr_bar()
  9. {
  10. MAX=$1
  11. PERCENT=0
  12. FOO=">"
  13. BAR=""
  14.  
  15. while [ $PERCENT -lt $(($MAX+1)) ]
  16. do
  17. echo -ne "\r\t[ "
  18. echo -ne "$BAR$FOO ] $((PERCENT*100/$MAX))% "
  19. BAR="${BAR}="
  20. let PERCENT=$PERCENT+1
  21. sleep 0.2
  22. done
  23.  
  24. echo -e " Done.\n"
  25. }
  26.  
  27. progr_bar 20

Report this snippet  

You need to login to post a comment.