Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- BATCHSIZE=1
- BAR_CHAR='|'
- PAD_CHAR=' '
- LENGTH=50
- BAR_POOL=$(eval "printf \"${BAR_CHAR}%.0s\" {1..$LENGTH}")
- PAD_POOL=$(eval "printf \"${PAD_CHAR}%.0s\" {1..$LENGTH}")
- # ##############################################################################
- progress-bar() {
- local current=$1
- local len=$2
- local perc_done=$((current * 100 / len))
- local num_bars=$((perc_done * LENGTH / 100))
- echo -ne "[${BAR_POOL:0:num_bars}${PAD_POOL:0:LENGTH-num_bars}] $current/$len ($perc_done%)\r"
- }
- process-files() {
- local files=("$@")
- sleep .01
- }
- # ##############################################################################
- shopt -s globstar nullglob
- echo 'finding files'
- files=(./**/*cache)
- len=${#files[@]}
- echo "found $len files"
- for ((i = 0; i < len; i += BATCHSIZE)); do
- progress-bar "$((i+1))" "$len"
- process-files "${files[@]:i:BATCHSIZE}"
- done
- progress-bar "$len" "$len"
- echo
Advertisement
Add Comment
Please, Sign In to add comment