View Single Post
Old 11-08-2004, 01:15 PM   #5 (permalink)
ender
Code Monkey
 
ender's Avatar
 
Join Date: Mar 2003
Location: Evansville, IN
Posts: 75
ender is on a distinguished road
Send a message via AIM to ender Send a message via Yahoo to ender
You should be able to do it in bash. Although determining the percentage to fill might be a little trickier than I would like it to be. The overall concept is the same though. I'm sure you knew this, but be sure to do 'echo -e' to enable interpretation of escape sequences. I think this may be dependent upon which shell you use. However I do know that /bin/echo is pretty much a constant.

The way you can do your percentages if you want to is to is pipe any calculation you want into bc and read the answer. For example, finding 2+2 : 'echo "2+2" | bc" will result in 4 on stdout.

The following should work for just a percentage though:

Code:
#!/bin/bash

echo "Start"

for i in 1 2 3 4
do
  percentage=`echo "scale=2; $i/4 * 100" | bc -l`
  echo -en "\r$percentage %"
  sleep 1
done

echo -e "\nDone!"
This should get you started. Oh, the -n option for echo suppresses the newline from being printed after the echo 'echos' something. Good Luck!

-Ted
__________________
while(1) fork();
ender is offline   Reply With Quote