Skip to content

Instantly share code, notes, and snippets.

@geta6
Last active December 31, 2015 11:59
Show Gist options
  • Save geta6/7983537 to your computer and use it in GitHub Desktop.
Save geta6/7983537 to your computer and use it in GitHub Desktop.
MAX=`echo "\`tput cols\` - 20" | bc`
PROGRESS() {
PRG=`echo "$1 * 100 / $2" | bc`
CUR=`echo "$MAX * $PRG / 100" | bc -l | cut -d'.' -f1`
STR='['
for i in `seq 1 $MAX`; do
if [[ $i -le $CUR ]]; then STR="$STR="; else STR="$STR "; fi
done
echo "$STR] $PRG%\r\c" >&2
}
echo
for i in {1..200}; do
PROGRESS $i 200
done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment