From 3627aa5fcb74959e95b8d291fc91e557a3dcc181 Mon Sep 17 00:00:00 2001 From: zegonix Date: Tue, 11 Aug 2026 09:33:38 +0200 Subject: [PATCH] (bash) rudimentary progressbar --- bash-test.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/bash-test.sh b/bash-test.sh index 10b1f29..59301da 100755 --- a/bash-test.sh +++ b/bash-test.sh @@ -1,6 +1,24 @@ #!/usr/bin/env bash -path="$(realpath "${BASH_SOURCE}")" +function print_progress { + bar='[ ' + for ((k = 0; k < 32; k++)); do + if ((k < (32 * ($2 + 1) / $1))); then + bar+='#' + else + bar+=' ' + fi + done + bar+=' ]' + echo -ne "\r${bar}" +} -echo "path: ${path%/*}" -echo "file: ${path##*/}" +files=($(find . -name "*.zig")) + +echo "${#files[@]}, ${#files}, ${files[@]}" + +for n in "${!files[@]}"; do + echo "${files[$n]}" + print_progress ${#files[@]} $n + sleep 1 +done