While loop animation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting While loop animation
# 1  
Old 04-13-2012
While loop animation

This is just for fun but i can't work it out

I want to animate this dotted line in a shell script.

..................................................................................

I want it to start at one dot like this

.

and end up printing them all.

I think I need a while loop but when I do it, it does this.

.
..
...
....

Any help please

Cheers
Dan
# 2  
Old 04-13-2012
Please post your sample code and mention what Operating System and version you have and what Shell you are using.
Your problem is that you need to append a dot to the dot string with no line-feed. The syntax to do this varies somewhat according to your local environment.
# 3  
Old 04-13-2012
In ksh or bash, something like this what you are wanting?

Code:
for (( i = 0; i < 30; i++ ))
do
    printf "."
    sleep 1
done
printf "\n"

The printf, without the \n, does not write a newline, so the next dot is placed on the same line as the previous. One final newline to make it nice when the script exits.
# 4  
Old 04-13-2012
OK

Code:
#!/bin/bash

i=1
while (( $i < 10 )); do
	echo .
	let i++
done

# 5  
Old 04-13-2012
Change your echo . to printf "." and then add a final printf with a newline (\n) after the while and you should be in business.
This User Gave Thanks to agama For This Post:
# 6  
Old 04-13-2012
Amazing cheers mate
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. What is on Your Mind?

Loading Animation for Large Man Page Repositories

Should have done this 10 years ago, so better late than never: Just added a "loading" animation to the the man page repositories when they load, especially since some are very large and take many seconds to load. See for example: https://www.unix.com/man-page-opensolaris-repository.php ... (1 Reply)
Discussion started by: Neo
1 Replies

2. What is on Your Mind?

Forum Description Animation with jQuery

I found that the pages that lists all the forums were too cluttered with the forum descriptions, so I added a bit of jQuery to hide the forum descriptions and to fade them in and out on mouseover: <script> $(document).ready(function() { jQuery(".neo-forum-description").hide();... (2 Replies)
Discussion started by: Neo
2 Replies

3. Shell Programming and Scripting

Gnuplot shell script controlled animation

Hi, I am looking for basic shell script to feed Gnuplot with live data, to arrange basic animation. I mean one-liner one variable real function. Any idea or experiences from the past, generating Gnuplot animation on dumb terminal (ASCII only) ? Or please refer me to a nice web site. ... (7 Replies)
Discussion started by: darius2
7 Replies

4. Shell Programming and Scripting

Shell Script Animation

Hi, I want to write a shell script which can do some animation The animation is as follows it is like a progress barwhich hould gone on inresing with time & at the end of the line there should be the progess Eg == - 10%... (2 Replies)
Discussion started by: wojtyla
2 Replies

5. UNIX for Dummies Questions & Answers

script animation

I have read hundreds of the postings and cannot find the answer to my question...so I hope that someone is able to answer it for me. I am writing a script in bash, and would like to add animation. I have a gif file that I would like to open and have displayed on the screen. Can this be done? Of... (0 Replies)
Discussion started by: debit
0 Replies

6. What is on Your Mind?

unix.com Flash animation

I realy Love the look of the Flash animation at top of the forum, very sweet. But it uses all of my cpu power :( even winamp starts getting little skips. Then i have to scroll down and hide the nice animation :( Maybe someone could try to tune it a little bit. Thats on a 1,6 Ghz... (0 Replies)
Discussion started by: Lazzar
0 Replies

7. UNIX Desktop Questions & Answers

3d animation

What are the benefits to using UNIX for 3d animation. I am looking into the field, and most places require a strong background in UNIX. Why is this? (3 Replies)
Discussion started by: aloysius1001
3 Replies

8. UNIX Desktop Questions & Answers

Graphics And Animation

DOES ANYBODY KNOW WHY C OR ANY OTHER UNIX LANGUAGE IS USED IN THREE DIMENSIONAL ANIMATION AND RENDERING (5 Replies)
Discussion started by: aloysius1001
5 Replies
Login or Register to Ask a Question