Last active
February 16, 2024 10:59
-
-
Save maurostorch/cc12739c8260e42b1f0802bc8cbccdfc to your computer and use it in GitHub Desktop.
progressbar in bash for anything
This file contains hidden or 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 | |
# could be placed in a single line | |
A=$1; # change to something with a number, first script's arg | |
B=$((A*40/$2)); # calculates the portion in a progress bar of 40 # where $2 is the total as 2nd script's arg | |
C=$((40-B)); # left | |
B=$(printf "%${B}s"); | |
C=$(printf "%${C}s"); | |
printf "\r[${B// /#}${C// /-}] $A%%\n" $A; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the result:
[########################----------------] 61%