View Single Post
Posts: 299 | Thanked: 557 times | Joined on Aug 2012
#4583
Hello Schturman,

This gave me a lot of headache but I finally worked it out. Bright side is no dependencies needed at all.
You can modify the bar charcacters as well as the length of the bar. Remember you can put a max of 45 characters in the bar because you have a start [ and end ] character which makes a total of 47 characters which is indeed are the max columns of N9 terminal. If you like we can get a landscape mod for this script.


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}' | sed 's/.$//')
wget $URL 2>/dev/null &

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

i=1

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

Last edited by brkn; 2012-11-10 at 15:53. Reason: formatting
 

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