Displaying and updating a counter in bash

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite
1












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"..










share|improve this question



























    up vote
    3
    down vote

    favorite
    1












    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"..










    share|improve this question

























      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      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"..










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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




















          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.






          share|improve this answer






















          • 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

















          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'





          share|improve this answer






















          • 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










          • @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 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

















          up vote
          0
          down vote













          https://github.com/extensionsapp/progre.sh



          Create 48 percent progress: progreSh 48



          enter image description here






          share|improve this answer








          New contributor




          Art Pip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            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






























            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.






            share|improve this answer






















            • 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














            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.






            share|improve this answer






















            • 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












            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.






            share|improve this 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.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            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 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
















            • 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















            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












            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'





            share|improve this answer






















            • 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










            • @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 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














            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'





            share|improve this answer






















            • 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










            • @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 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












            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'





            share|improve this answer














            Are you looking for something like this?



            for i in 1..10; do 
            printf 'r%2d' $i
            sleep 1
            done
            printf 'n'






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 31 '11 at 0:51

























            answered Aug 30 '11 at 14:07









            enzotib

            33k710292




            33k710292











            • 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










            • @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 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
















            • 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










            • @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 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















            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










            up vote
            0
            down vote













            https://github.com/extensionsapp/progre.sh



            Create 48 percent progress: progreSh 48



            enter image description here






            share|improve this answer








            New contributor




            Art Pip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















              up vote
              0
              down vote













              https://github.com/extensionsapp/progre.sh



              Create 48 percent progress: progreSh 48



              enter image description here






              share|improve this answer








              New contributor




              Art Pip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.



















                up vote
                0
                down vote










                up vote
                0
                down vote









                https://github.com/extensionsapp/progre.sh



                Create 48 percent progress: progreSh 48



                enter image description here






                share|improve this answer








                New contributor




                Art Pip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                https://github.com/extensionsapp/progre.sh



                Create 48 percent progress: progreSh 48



                enter image description here







                share|improve this answer








                New contributor




                Art Pip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                Art Pip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 14 mins ago









                Art Pip

                101




                101




                New contributor




                Art Pip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Art Pip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Art Pip is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    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













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay