progress_bar() {
local current="$1" total="$2" width="${3:-40}"
local pct=$(( current * 100 / total ))
local filled=$(( current * width / total ))
local empty=$(( width - filled ))
printf "\r[%s%s] %d%% (%d/%d)" \
"$(printf '█%.0s' $(seq 1 $filled))" \
"$(printf '░%.0s' $(seq 1 $empty))" \
"$pct" "$current" "$total"
}
TOTAL=50
for i in $(seq 1 $TOTAL); do
sleep 0.05 # imagine real work here
progress_bar "$i" "$TOTAL"
done
echo # newline after the bar
Create a free account and build your private vault. Share publicly whenever you want.