Register
It is currently Wed Oct 01, 2014 8:15 am

Create loading for script (basic)


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Jan 26, 2010 12:24 pm   

Joined: Tue Jan 26, 2010 10:56 am
Posts: 1
I'm new to scripting, and I want to create my own loading
this is what I got so far:

Code:
#!/bin/bash
TEXT="Loading "
for ((i=0; i<20; i+=1)); do
      clear
      TEXT+=.
      echo $TEXT
      sleep 1
done
echo "Done!"

This shows dots that look like a loading.
Example: Loading ................
An extra dot is added every second.
What I want is, that those dots load on one line, that's why I used the 'clear' command.
Is there a way that the dots load on one line without 'clearing' the screen?

Greets


Top
 Profile  
 PostPosted: Tue Jan 26, 2010 2:26 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 549
Hi Nix,

simply
Code:
var="."
echo -n "Loading"
for (( i=0; i<20; i++ ))
do
   echo -n "$var"
   sleep 1
done
echo "done!"


Top
 Profile  
 PostPosted: Thu Jan 28, 2010 2:44 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
This is a wget style progress bar that I wrote a while back, it should be modifiable to be used as a loading bar :)

Code:
max=68
for ((i = 0; $i <= $max; i++)); do
   procent=$((($i * 100) / $max))
   out="["
   for ((j = 0; $j < $i; j++)); do
      out="$out$(echo -n "=")"
   done
   out="$out>"
   a=$((max - i))
   for ((j = 0; $j < $a; j++)); do
      out="$out$(echo -e " \c")"
   done
   out="$out]";
   echo -e "$out $procent%\r\c"
   sleep 1
done
echo


Best regards
Fredrik Eriksson


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP