#!/bin/bash # Usage: # speedy.sh [] clear OLDFILESIZE=`ls -al "$1" | awk '{print \$5}'` SECS=`date +%s` sleep 1 while true; do FILESIZE=`ls -al "$1" | awk '{print \$5}'` # Bugfix. Now the time is more accurate. OLDSECS=$SECS SECS=`date +%s` let "SECDIFF = $SECS - $OLDSECS" let "DIFF = $FILESIZE - $OLDFILESIZE" let "SPEED = $DIFF / $SECDIFF / 1024" if [ $2 ] then if [ $DIFF -eq 0 ] then ETA='\033[01;31mstalled!\033[00m' ETAM="" else let "ETA = (($2*1024*1024) - $FILESIZE )* $SECDIFF / $DIFF" let "ETAM = $ETA/60" ETA="\\033[01;32m$ETA\\033[00m s" ETAM="\\033[01;32m$ETAM\\033[00m m" fi echo -e "Filesize: \\033[01;33m$2\\033[00m MB | Downloaded: \\033[01;33m$FILESIZE\\033[00m bytes" echo -e "$1 download speed = $SPEED Kb/s | ETA: $ETA - $ETAM" echo -n "Press any key to exit" if read -t 3 response then exit fi else echo "Downloaded: $FILESIZE bytes" echo "$1 download speed = $SPEED Kb/s" echo -n "Press any key to exit" if read -t 3 response then exit fi fi let "OLDFILESIZE = $FILESIZE" clear done