Last active
April 29, 2016 03:19
-
-
Save lsongdev/332b80f24e7f203987eff11fc6765bd8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# example: | |
# | |
# curl -s https://gist.githubusercontent.com/song940/332b80f24e7f203987eff11fc6765bd8/raw/progressbar.sh | sh | |
# | |
function ProgressBar(){ | |
let max=$1 | |
let done=$2 | |
let left=$max-$done | |
let current=($done*100/$max*100)/100 | |
local fill=$(printf "%${done}s") | |
local empty=$(printf "%${left}s") | |
printf "\r [${fill// /#}${empty// /-}] ${current}%%" | |
} | |
for i in {1..70}; do | |
ProgressBar 70 $i | |
sleep 0.1 | |
done | |
printf "\nFinished!\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
始终在一行输出是什么原理?