-
-
Save c00kiemon5ter/1794917 to your computer and use it in GitHub Desktop.
cp wrapper with a progressbar
This file contains 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 | |
current=0 | |
completed=0 | |
read -r total _ < <(/bin/du -bc "${@:1:${#}-1}" | tail -n1) | |
/bin/cp $@ & | |
while (( current != total )); do | |
read -r current _ < <(/bin/du -bc "${!#}" | tail -n1) | |
completed="$((current * 100 / total ))" | |
lines="$((completed * ($(tput cols) - 1 - 5) / 100))" | |
printf -- "\r%3d%% " "$completed" | |
for ((i=0; i<$lines; i++)); do printf -- "%s" "="; done | |
done | |
printf -- ">\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ofcourse many problems lying around
oeople should use stuff like
pv
, this was hacked for fun,and if used it's better of with only one soure and target file.