Displaying and updating a counter in bash
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I think it's something like this: (Fedora14/bash)
#!/bin/bash
for i in 0..10..1; do echo -e "$i"'c'
echo -e "nr"
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"..
bash shell terminal control-flow
add a comment |Â
up vote
3
down vote
favorite
I think it's something like this: (Fedora14/bash)
#!/bin/bash
for i in 0..10..1; do echo -e "$i"'c'
echo -e "nr"
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"..
bash shell terminal control-flow
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I think it's something like this: (Fedora14/bash)
#!/bin/bash
for i in 0..10..1; do echo -e "$i"'c'
echo -e "nr"
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"..
bash shell terminal control-flow
I think it's something like this: (Fedora14/bash)
#!/bin/bash
for i in 0..10..1; do echo -e "$i"'c'
echo -e "nr"
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"..
bash shell terminal control-flow
bash shell terminal control-flow
edited Sep 17 '11 at 17:04
Michael Mrozekâ¦
59.5k27187208
59.5k27187208
asked Aug 30 '11 at 13:57
LanceBaynes
9,96675190321
9,96675190321
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
7
down vote
accepted
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.
You can also just use oner
instead of all theb
's.
â rozcietrzewiacz
Aug 30 '11 at 15:06
Yes, thanks, I changed my post accordingly.
â user unknown
Aug 30 '11 at 21:17
add a comment |Â
up vote
1
down vote
Are you looking for something like this?
for i in 1..10; do
printf 'r%2d' $i
sleep 1
done
printf 'n'
Why the firstprintf
?
â rozcietrzewiacz
Aug 30 '11 at 14:40
It would make sense if you were counting backwards from 10 to 1
â glenn jackman
Aug 30 '11 at 14:44
@rozcietrzewiacz and glenn jackman: I think i put it, without thinking too much, remembering a case where the numbers had different lengths, so that something old could be leaved on screen.
â enzotib
Aug 30 '11 at 14:56
@glen Really? How exactly?
â rozcietrzewiacz
Aug 30 '11 at 15:02
I missed the '%2d' in the next printf. If it had just beenfor i in 10..1..-1; do printf "r%d" $i; sleep 1; done
then you would have seen 10, 90, 80, 70, etc
â glenn jackman
Aug 30 '11 at 15:34
 |Â
show 1 more comment
up vote
0
down vote
https://github.com/extensionsapp/progre.sh
Create 48 percent progress: progreSh 48
New contributor
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
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.
You can also just use oner
instead of all theb
's.
â rozcietrzewiacz
Aug 30 '11 at 15:06
Yes, thanks, I changed my post accordingly.
â user unknown
Aug 30 '11 at 21:17
add a comment |Â
up vote
7
down vote
accepted
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.
You can also just use oner
instead of all theb
's.
â rozcietrzewiacz
Aug 30 '11 at 15:06
Yes, thanks, I changed my post accordingly.
â user unknown
Aug 30 '11 at 21:17
add a comment |Â
up vote
7
down vote
accepted
up vote
7
down vote
accepted
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.
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.
edited Aug 30 '11 at 21:00
answered Aug 30 '11 at 14:09
user unknown
7,11412148
7,11412148
You can also just use oner
instead of all theb
's.
â rozcietrzewiacz
Aug 30 '11 at 15:06
Yes, thanks, I changed my post accordingly.
â user unknown
Aug 30 '11 at 21:17
add a comment |Â
You can also just use oner
instead of all theb
's.
â rozcietrzewiacz
Aug 30 '11 at 15:06
Yes, thanks, I changed my post accordingly.
â user unknown
Aug 30 '11 at 21:17
You can also just use one
r
instead of all the b
's.â rozcietrzewiacz
Aug 30 '11 at 15:06
You can also just use one
r
instead of all the b
's.â rozcietrzewiacz
Aug 30 '11 at 15:06
Yes, thanks, I changed my post accordingly.
â user unknown
Aug 30 '11 at 21:17
Yes, thanks, I changed my post accordingly.
â user unknown
Aug 30 '11 at 21:17
add a comment |Â
up vote
1
down vote
Are you looking for something like this?
for i in 1..10; do
printf 'r%2d' $i
sleep 1
done
printf 'n'
Why the firstprintf
?
â rozcietrzewiacz
Aug 30 '11 at 14:40
It would make sense if you were counting backwards from 10 to 1
â glenn jackman
Aug 30 '11 at 14:44
@rozcietrzewiacz and glenn jackman: I think i put it, without thinking too much, remembering a case where the numbers had different lengths, so that something old could be leaved on screen.
â enzotib
Aug 30 '11 at 14:56
@glen Really? How exactly?
â rozcietrzewiacz
Aug 30 '11 at 15:02
I missed the '%2d' in the next printf. If it had just beenfor i in 10..1..-1; do printf "r%d" $i; sleep 1; done
then you would have seen 10, 90, 80, 70, etc
â glenn jackman
Aug 30 '11 at 15:34
 |Â
show 1 more comment
up vote
1
down vote
Are you looking for something like this?
for i in 1..10; do
printf 'r%2d' $i
sleep 1
done
printf 'n'
Why the firstprintf
?
â rozcietrzewiacz
Aug 30 '11 at 14:40
It would make sense if you were counting backwards from 10 to 1
â glenn jackman
Aug 30 '11 at 14:44
@rozcietrzewiacz and glenn jackman: I think i put it, without thinking too much, remembering a case where the numbers had different lengths, so that something old could be leaved on screen.
â enzotib
Aug 30 '11 at 14:56
@glen Really? How exactly?
â rozcietrzewiacz
Aug 30 '11 at 15:02
I missed the '%2d' in the next printf. If it had just beenfor i in 10..1..-1; do printf "r%d" $i; sleep 1; done
then you would have seen 10, 90, 80, 70, etc
â glenn jackman
Aug 30 '11 at 15:34
 |Â
show 1 more comment
up vote
1
down vote
up vote
1
down vote
Are you looking for something like this?
for i in 1..10; do
printf 'r%2d' $i
sleep 1
done
printf 'n'
Are you looking for something like this?
for i in 1..10; do
printf 'r%2d' $i
sleep 1
done
printf 'n'
edited Aug 31 '11 at 0:51
answered Aug 30 '11 at 14:07
enzotib
33k710292
33k710292
Why the firstprintf
?
â rozcietrzewiacz
Aug 30 '11 at 14:40
It would make sense if you were counting backwards from 10 to 1
â glenn jackman
Aug 30 '11 at 14:44
@rozcietrzewiacz and glenn jackman: I think i put it, without thinking too much, remembering a case where the numbers had different lengths, so that something old could be leaved on screen.
â enzotib
Aug 30 '11 at 14:56
@glen Really? How exactly?
â rozcietrzewiacz
Aug 30 '11 at 15:02
I missed the '%2d' in the next printf. If it had just beenfor i in 10..1..-1; do printf "r%d" $i; sleep 1; done
then you would have seen 10, 90, 80, 70, etc
â glenn jackman
Aug 30 '11 at 15:34
 |Â
show 1 more comment
Why the firstprintf
?
â rozcietrzewiacz
Aug 30 '11 at 14:40
It would make sense if you were counting backwards from 10 to 1
â glenn jackman
Aug 30 '11 at 14:44
@rozcietrzewiacz and glenn jackman: I think i put it, without thinking too much, remembering a case where the numbers had different lengths, so that something old could be leaved on screen.
â enzotib
Aug 30 '11 at 14:56
@glen Really? How exactly?
â rozcietrzewiacz
Aug 30 '11 at 15:02
I missed the '%2d' in the next printf. If it had just beenfor i in 10..1..-1; do printf "r%d" $i; sleep 1; done
then you would have seen 10, 90, 80, 70, etc
â glenn jackman
Aug 30 '11 at 15:34
Why the first
printf
?â rozcietrzewiacz
Aug 30 '11 at 14:40
Why the first
printf
?â rozcietrzewiacz
Aug 30 '11 at 14:40
It would make sense if you were counting backwards from 10 to 1
â glenn jackman
Aug 30 '11 at 14:44
It would make sense if you were counting backwards from 10 to 1
â glenn jackman
Aug 30 '11 at 14:44
@rozcietrzewiacz and glenn jackman: I think i put it, without thinking too much, remembering a case where the numbers had different lengths, so that something old could be leaved on screen.
â enzotib
Aug 30 '11 at 14:56
@rozcietrzewiacz and glenn jackman: I think i put it, without thinking too much, remembering a case where the numbers had different lengths, so that something old could be leaved on screen.
â enzotib
Aug 30 '11 at 14:56
@glen Really? How exactly?
â rozcietrzewiacz
Aug 30 '11 at 15:02
@glen Really? How exactly?
â rozcietrzewiacz
Aug 30 '11 at 15:02
I missed the '%2d' in the next printf. If it had just been
for i in 10..1..-1; do printf "r%d" $i; sleep 1; done
then you would have seen 10, 90, 80, 70, etcâ glenn jackman
Aug 30 '11 at 15:34
I missed the '%2d' in the next printf. If it had just been
for i in 10..1..-1; do printf "r%d" $i; sleep 1; done
then you would have seen 10, 90, 80, 70, etcâ glenn jackman
Aug 30 '11 at 15:34
 |Â
show 1 more comment
up vote
0
down vote
https://github.com/extensionsapp/progre.sh
Create 48 percent progress: progreSh 48
New contributor
add a comment |Â
up vote
0
down vote
https://github.com/extensionsapp/progre.sh
Create 48 percent progress: progreSh 48
New contributor
add a comment |Â
up vote
0
down vote
up vote
0
down vote
https://github.com/extensionsapp/progre.sh
Create 48 percent progress: progreSh 48
New contributor
https://github.com/extensionsapp/progre.sh
Create 48 percent progress: progreSh 48
New contributor
New contributor
answered 14 mins ago
Art Pip
101
101
New contributor
New contributor
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f19756%2fdisplaying-and-updating-a-counter-in-bash%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password