find -type f -ls | awk '{total += $7} END {print total}'
du -b ./* | awk '{total += $1} END {print total}'
origin=0target=0copied=0tFiles=`ls tmp`all=falsefor f in done/*do getSize $f origin=$(($origin + $ret)) if [[ $csys == false ]] then if [[ $tFiles == *`basename $f`* && $all == false ]] then echo ">>> The target device already contains files from Done directory..."; echo ">>> Overwrite it? (all/y/n)" read overwrite if [ "$overwrite" = "y" ] then rm tmp/`basename $f` elif [ "$overwrite" = "all" ] then all=true rm tmp/`basename $f` else getSize tmp/`basename $f` target=$(($target + $ret)) fi elif [[ $tFiles == *`basename $f`* ]] then rm tmp/`basename $f` fi fidonecp done/* tmp &while [ $origin -gt $copied ]do copied=$((`du -bc tmp/* | tail -1 | sed -e 's/\s.*//'` - $target)) pct=$((100 * $copied / $origin)) echo -en "\r>>> Progress: ${pct}%\r" sleep 1doneecho ">>> Unmounting the target device..."umount tmp