Repeat 3000 times a sequence of characters “OW HW1 HW2” in a column

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











up vote
1
down vote

favorite












I would like to have the following sequence:
OW
HW1
HW2
being repeated in an output file 3000 times such as:



OW
HW1
HW2
.
.
.
OW
HW1
HW2


I believe I can, by using bash, set the OW, HW1 and HW2 as independent variable and then make a do loop 3000 times and print the values in the output file.










share|improve this question



























    up vote
    1
    down vote

    favorite












    I would like to have the following sequence:
    OW
    HW1
    HW2
    being repeated in an output file 3000 times such as:



    OW
    HW1
    HW2
    .
    .
    .
    OW
    HW1
    HW2


    I believe I can, by using bash, set the OW, HW1 and HW2 as independent variable and then make a do loop 3000 times and print the values in the output file.










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I would like to have the following sequence:
      OW
      HW1
      HW2
      being repeated in an output file 3000 times such as:



      OW
      HW1
      HW2
      .
      .
      .
      OW
      HW1
      HW2


      I believe I can, by using bash, set the OW, HW1 and HW2 as independent variable and then make a do loop 3000 times and print the values in the output file.










      share|improve this question















      I would like to have the following sequence:
      OW
      HW1
      HW2
      being repeated in an output file 3000 times such as:



      OW
      HW1
      HW2
      .
      .
      .
      OW
      HW1
      HW2


      I believe I can, by using bash, set the OW, HW1 and HW2 as independent variable and then make a do loop 3000 times and print the values in the output file.







      bash






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 36 mins ago









      Rui F Ribeiro

      37.1k1273118




      37.1k1273118










      asked 2 hours ago









      Dimitris Mintis

      161




      161




















          5 Answers
          5






          active

          oldest

          votes

















          up vote
          4
          down vote













          You can use this printf trick with a zero-length string specifier %.0s and brace expansion:



          printf '%.0sOWnHW1nHW2n' 1..3000 > newfile





          share|improve this answer




















          • super this works just perfect!!!!
            – Dimitris Mintis
            1 hour ago

















          up vote
          2
          down vote













          It can be easily done with Perl:



          perl -e'print "OWnHW1nHW2n"x3000'





          share|improve this answer



























            up vote
            1
            down vote













            If use for in cycle:



            for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done


            or use echo 3x



            for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done





            share|improve this answer




















            • This is great, but then how do I print this sequence 3000 times in the file?
              – Dimitris Mintis
              1 hour ago










            • Use redirection: for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
              – schweik
              1 hour ago


















            up vote
            0
            down vote













            you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html



            An example:



            COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done


            Don't forget to reset the COUNTER every time you want to run this.






            share|improve this answer








            New contributor




            Timo 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













              If your shell offers "brace expansion", try



              echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
              OH
              HW1
              HW2
              OH
              HW1
              HW2
              OH
              HW1
              HW2
              .
              .
              .


              and redirect to a file if happy with the result.






              share|improve this answer




















                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: false,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                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%2f475040%2frepeat-3000-times-a-sequence-of-characters-ow-hw1-hw2-in-a-column%23new-answer', 'question_page');

                );

                Post as a guest






























                5 Answers
                5






                active

                oldest

                votes








                5 Answers
                5






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                4
                down vote













                You can use this printf trick with a zero-length string specifier %.0s and brace expansion:



                printf '%.0sOWnHW1nHW2n' 1..3000 > newfile





                share|improve this answer




















                • super this works just perfect!!!!
                  – Dimitris Mintis
                  1 hour ago














                up vote
                4
                down vote













                You can use this printf trick with a zero-length string specifier %.0s and brace expansion:



                printf '%.0sOWnHW1nHW2n' 1..3000 > newfile





                share|improve this answer




















                • super this works just perfect!!!!
                  – Dimitris Mintis
                  1 hour ago












                up vote
                4
                down vote










                up vote
                4
                down vote









                You can use this printf trick with a zero-length string specifier %.0s and brace expansion:



                printf '%.0sOWnHW1nHW2n' 1..3000 > newfile





                share|improve this answer












                You can use this printf trick with a zero-length string specifier %.0s and brace expansion:



                printf '%.0sOWnHW1nHW2n' 1..3000 > newfile






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 1 hour ago









                steeldriver

                32.9k34981




                32.9k34981











                • super this works just perfect!!!!
                  – Dimitris Mintis
                  1 hour ago
















                • super this works just perfect!!!!
                  – Dimitris Mintis
                  1 hour ago















                super this works just perfect!!!!
                – Dimitris Mintis
                1 hour ago




                super this works just perfect!!!!
                – Dimitris Mintis
                1 hour ago












                up vote
                2
                down vote













                It can be easily done with Perl:



                perl -e'print "OWnHW1nHW2n"x3000'





                share|improve this answer
























                  up vote
                  2
                  down vote













                  It can be easily done with Perl:



                  perl -e'print "OWnHW1nHW2n"x3000'





                  share|improve this answer






















                    up vote
                    2
                    down vote










                    up vote
                    2
                    down vote









                    It can be easily done with Perl:



                    perl -e'print "OWnHW1nHW2n"x3000'





                    share|improve this answer












                    It can be easily done with Perl:



                    perl -e'print "OWnHW1nHW2n"x3000'






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 1 hour ago









                    Tomasz

                    8,50552760




                    8,50552760




















                        up vote
                        1
                        down vote













                        If use for in cycle:



                        for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done


                        or use echo 3x



                        for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done





                        share|improve this answer




















                        • This is great, but then how do I print this sequence 3000 times in the file?
                          – Dimitris Mintis
                          1 hour ago










                        • Use redirection: for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
                          – schweik
                          1 hour ago















                        up vote
                        1
                        down vote













                        If use for in cycle:



                        for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done


                        or use echo 3x



                        for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done





                        share|improve this answer




















                        • This is great, but then how do I print this sequence 3000 times in the file?
                          – Dimitris Mintis
                          1 hour ago










                        • Use redirection: for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
                          – schweik
                          1 hour ago













                        up vote
                        1
                        down vote










                        up vote
                        1
                        down vote









                        If use for in cycle:



                        for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done


                        or use echo 3x



                        for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done





                        share|improve this answer












                        If use for in cycle:



                        for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done


                        or use echo 3x



                        for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 1 hour ago









                        schweik

                        3004




                        3004











                        • This is great, but then how do I print this sequence 3000 times in the file?
                          – Dimitris Mintis
                          1 hour ago










                        • Use redirection: for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
                          – schweik
                          1 hour ago

















                        • This is great, but then how do I print this sequence 3000 times in the file?
                          – Dimitris Mintis
                          1 hour ago










                        • Use redirection: for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
                          – schweik
                          1 hour ago
















                        This is great, but then how do I print this sequence 3000 times in the file?
                        – Dimitris Mintis
                        1 hour ago




                        This is great, but then how do I print this sequence 3000 times in the file?
                        – Dimitris Mintis
                        1 hour ago












                        Use redirection: for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
                        – schweik
                        1 hour ago





                        Use redirection: for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
                        – schweik
                        1 hour ago











                        up vote
                        0
                        down vote













                        you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html



                        An example:



                        COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done


                        Don't forget to reset the COUNTER every time you want to run this.






                        share|improve this answer








                        New contributor




                        Timo 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













                          you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html



                          An example:



                          COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done


                          Don't forget to reset the COUNTER every time you want to run this.






                          share|improve this answer








                          New contributor




                          Timo 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









                            you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html



                            An example:



                            COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done


                            Don't forget to reset the COUNTER every time you want to run this.






                            share|improve this answer








                            New contributor




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









                            you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html



                            An example:



                            COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done


                            Don't forget to reset the COUNTER every time you want to run this.







                            share|improve this answer








                            New contributor




                            Timo 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




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









                            answered 1 hour ago









                            Timo

                            11




                            11




                            New contributor




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





                            New contributor





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






                            Timo 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













                                If your shell offers "brace expansion", try



                                echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
                                OH
                                HW1
                                HW2
                                OH
                                HW1
                                HW2
                                OH
                                HW1
                                HW2
                                .
                                .
                                .


                                and redirect to a file if happy with the result.






                                share|improve this answer
























                                  up vote
                                  0
                                  down vote













                                  If your shell offers "brace expansion", try



                                  echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
                                  OH
                                  HW1
                                  HW2
                                  OH
                                  HW1
                                  HW2
                                  OH
                                  HW1
                                  HW2
                                  .
                                  .
                                  .


                                  and redirect to a file if happy with the result.






                                  share|improve this answer






















                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    If your shell offers "brace expansion", try



                                    echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
                                    OH
                                    HW1
                                    HW2
                                    OH
                                    HW1
                                    HW2
                                    OH
                                    HW1
                                    HW2
                                    .
                                    .
                                    .


                                    and redirect to a file if happy with the result.






                                    share|improve this answer












                                    If your shell offers "brace expansion", try



                                    echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
                                    OH
                                    HW1
                                    HW2
                                    OH
                                    HW1
                                    HW2
                                    OH
                                    HW1
                                    HW2
                                    .
                                    .
                                    .


                                    and redirect to a file if happy with the result.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 1 hour ago









                                    RudiC

                                    1,90219




                                    1,90219



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f475040%2frepeat-3000-times-a-sequence-of-characters-ow-hw1-hw2-in-a-column%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Comments

                                        Popular posts from this blog

                                        What does second last employer means? [closed]

                                        Installing NextGIS Connect into QGIS 3?

                                        One-line joke