Created
October 19, 2012 07:16
-
-
Save ze-/3916683 to your computer and use it in GitHub Desktop.
Shows progress of a copy
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 | |
function myhelp() { | |
printf "Usage:\n\t$(basename $1)";shift;printf " $*" >/dev/stderr | |
exit 1 | |
} | |
[ $# -lt 2 ] && myhelp $0 "<source> <destination>\n | |
Calculates %% complete of a copy from <source> to <destination> | |
Can be started before (or after) <destination> exists.\n\n" | |
pcsrc=$(du -bsL "$1" | cut -f1) | |
pcdst=1 | |
while [[ $pcsrc -gt $pcdst ]];do | |
pcdst=$(du -bsL "$2" 2>/dev/null| cut -f1) | |
printf "\r$2: $(((pcdst*100)/pcsrc))%%" | |
sleep 0.2 | |
done | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment