Skip to content

Instantly share code, notes, and snippets.

@ze-
Created October 19, 2012 07:16
Show Gist options
  • Save ze-/3916683 to your computer and use it in GitHub Desktop.
Save ze-/3916683 to your computer and use it in GitHub Desktop.
Shows progress of a copy
#!/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