Last active
July 28, 2017 15:24
-
-
Save linknum23/797520bf97d58df87ff40795b26445a4 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# modification of https://github.com/fearside/ProgressBar/ | |
# 1. Create ProgressBar function | |
# 1.1 Input is currentState($1) and totalState($2) | |
function ProgressBar { | |
# Process data | |
let _progress=(${1}*100/${2}*100)/100 | |
let _done=(${_progress}*4)/10 | |
let _left=40-$_done | |
# Build progressbar string lengths | |
_fill=$(printf "%${_done}s") | |
_empty=$(printf "%${_left}s") | |
# 1.2 Build progressbar strings and print the ProgressBar line | |
# 1.2.1 Output example: | |
# 1.2.1.1 Progress : [########################################] 100% | |
if [ $_left -eq 0 ] | |
then | |
# clear our the progress bar | |
printf "\r\033[K" | |
else | |
printf "\rProgress : [${_fill// /#}${_empty// /-}] ${_progress}%%" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment