A very simple bash progress bar.


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  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

URL: http://identi.ca/ksaver

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.