Bash – Displaying and Updating a Counter

bashcontrol flowshellterminal

I think it's something like this: (Fedora14/bash)

#!/bin/bash

for i in {0..10..1}; do echo -e "$i"'\c'
echo -e "\n\r"
sleep 1
done

But it doesn't work.
Purpose: like this, but without the "clear":

#!/bin/bash

for i in {0..10..1}; do echo -e "$i"
sleep 1
clear
done

So a counting script that doesn't deletes the whole screen to output +1 number, instead it only deletes the line, where the counting is, so that there could be ex.: a beatifull "progress bar"..

Best Answer

for i in {0..15}; do echo -ne "$i"'\r'; sleep 1; done; echo 

You don't need ..1 for stepwidth 1 which is default.

echo -n 

prevents newlines.

\r is returning to begin of line (without newline - \n), and better than my formerly used '\b' for backstepping a single character, unhandy, if you have more than one digit-numbers. Thanks to rozcietrzewiacz.