Created
December 30, 2017 23:17
-
-
Save rajiteh/82d7d9628dc43de1f22392aaefc6cc3d to your computer and use it in GitHub Desktop.
meh
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 | |
## ./script path1 path2 | |
src=$1 | |
dst=$2 | |
function percentage { | |
jq -n "$(du -s $1 | cut -f1)/$(du -s $2 | cut -f1)*100" | |
} | |
cat last_check || : | |
result_1=$(percentage) | |
sleep 1 | |
result_2=$(percentage) | |
touch check_diff | |
jq -n "$result_2 - $result_1" >> check_diff | |
avg=$(awk '{s+=$1}END{print (NR?s/NR:"0")}' RS=" " check_diff) | |
secs=$(jq -n "(100-$result_2)/$avg|floor") | |
printf 'Completion: %f%%\nETA: %dh:%dm:%ds\n' $result_2 $(($secs/3600)) $(($secs%3600/60)) $(($secs%60)) > last_check | |
if [ "$(cat check_diff |wc -l)" -gt 50 ]; then | |
echo "$(tail -25 check_diff)" > check_diff | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment