View Single Post
Posts: 299 | Thanked: 557 times | Joined on Aug 2012
#4589
Originally Posted by Schturman View Post
second one
thanks
Code:
#!/bin/bash

bar="========================================"
barlength=${#bar}
URL="https://dl.dropbox.com/u/17706605/N9_QuickTweak_en_v9.4.pdf"
FILE=$(basename $URL)
rm -f "$FILE"
length=$(curl --head $URL 2>&1 | grep Content-Length | awk '{print $2}')
wget -q $URL 2>/dev/null &

while [ ! -f "$FILE" ] ;
do
      sleep 0.1
done

i=$(stat "$FILE" | grep Size | awk '{print $2}')

while [[ $i -lt $length ]]; do
  i=$(stat "$FILE" | grep Size | awk '{print $2}')
  n=$(($i * $barlength / $length))
  percent=$((100 * $i / $length))
  printf "\r[%-${barlength}s]" "${bar:0:n}"
  printf " $percent%%"
  sleep 0.1
done
printf "\n"
 

The Following 2 Users Say Thank You to brkn For This Useful Post: