How do I generate a sequence of numbers like this?

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












1















I am trying to generate a sequence of numbers where it adds 1 every other time, and 39999 every other time. Example of list which does what I want up to a million:



1 40000
40001 80000
80001 120000
120001 160000
160001 200000
200001 240000
240001 280000
280001 320000
320001 360000
360000 400000
400001 440000
440001 480000
480001 520000
520001 560000
560001 600000
600001 640000
640001 680000
680001 720000
720001 760000
760001 800000
800001 840000
840001 880000
880001 920000
920001 960000
960001 1000000


I have tried using seq, but I did not find a way to change the increment every other time.










share|improve this question




























    1















    I am trying to generate a sequence of numbers where it adds 1 every other time, and 39999 every other time. Example of list which does what I want up to a million:



    1 40000
    40001 80000
    80001 120000
    120001 160000
    160001 200000
    200001 240000
    240001 280000
    280001 320000
    320001 360000
    360000 400000
    400001 440000
    440001 480000
    480001 520000
    520001 560000
    560001 600000
    600001 640000
    640001 680000
    680001 720000
    720001 760000
    760001 800000
    800001 840000
    840001 880000
    880001 920000
    920001 960000
    960001 1000000


    I have tried using seq, but I did not find a way to change the increment every other time.










    share|improve this question


























      1












      1








      1








      I am trying to generate a sequence of numbers where it adds 1 every other time, and 39999 every other time. Example of list which does what I want up to a million:



      1 40000
      40001 80000
      80001 120000
      120001 160000
      160001 200000
      200001 240000
      240001 280000
      280001 320000
      320001 360000
      360000 400000
      400001 440000
      440001 480000
      480001 520000
      520001 560000
      560001 600000
      600001 640000
      640001 680000
      680001 720000
      720001 760000
      760001 800000
      800001 840000
      840001 880000
      880001 920000
      920001 960000
      960001 1000000


      I have tried using seq, but I did not find a way to change the increment every other time.










      share|improve this question
















      I am trying to generate a sequence of numbers where it adds 1 every other time, and 39999 every other time. Example of list which does what I want up to a million:



      1 40000
      40001 80000
      80001 120000
      120001 160000
      160001 200000
      200001 240000
      240001 280000
      280001 320000
      320001 360000
      360000 400000
      400001 440000
      440001 480000
      480001 520000
      520001 560000
      560001 600000
      600001 640000
      640001 680000
      680001 720000
      720001 760000
      760001 800000
      800001 840000
      840001 880000
      880001 920000
      920001 960000
      960001 1000000


      I have tried using seq, but I did not find a way to change the increment every other time.







      bash seq






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 13 at 21:23







      Seqeur

















      asked Jan 13 at 21:18









      SeqeurSeqeur

      133




      133




















          3 Answers
          3






          active

          oldest

          votes


















          4














          Output the sequence "manually" using



          i=0
          while [ "$i" -lt 1000000 ]; do
          printf '%d %dn' "$(( i+1 ))" "$(( i += 40000 ))"
          done


          or



          for (( i = 1; i < 1000000; i += 40000 )); do
          printf '%d %dn' "$i" "$(( i + 39999 ))"
          done


          or something like it.



          Or paste together two separate sequences from seq:



          $ paste <( seq 1 40000 1000000 ) <( seq 40000 40000 1000000 )
          1 40000
          40001 80000
          80001 120000
          120001 160000
          160001 200000
          200001 240000
          240001 280000
          280001 320000
          320001 360000
          360001 400000
          400001 440000
          440001 480000
          480001 520000
          520001 560000
          560001 600000
          600001 640000
          640001 680000
          680001 720000
          720001 760000
          760001 800000
          800001 840000
          840001 880000
          880001 920000
          920001 960000
          960001 1000000


          Suggested by JdeBP in comments:



          jot - 1 1000000 40000 | awk ' print $1, $1+39999 '


          but it's essentially the same as the second loop at the top, and since seq is more readily available on Linux machines (jot is originally a BSD utility, while seq is part of GNU coreutils), and the most common visitor here is a Linux user, and the question was tagged with seq, it may be more usefully written as



          seq 1 40000 1000000 | awk ' print $1, $1+39999 '





          share|improve this answer

























          • Don't forget the option of piping jot into awk. (-:

            – JdeBP
            Jan 13 at 21:36











          • Yeah, and you should also put a cat (or two tac(1)s) between jot and awk.

            – mosvy
            Jan 13 at 21:55












          • @mosvy A cat in a pipeline is (often) a sad cat.

            – Kusalananda
            Jan 13 at 22:01



















          4














          Enjoy a single AWK expression :)



          awk 'BEGIN while (c < 1000000) print (++c, c += 39999) '



          • ++c - pre increment variable

          The output:



          1 40000
          40001 80000
          80001 120000
          120001 160000
          160001 200000
          200001 240000
          240001 280000
          280001 320000
          320001 360000
          360001 400000
          400001 440000
          440001 480000
          480001 520000
          520001 560000
          560001 600000
          600001 640000
          640001 680000
          680001 720000
          720001 760000
          760001 800000
          800001 840000
          840001 880000
          880001 920000
          920001 960000
          960001 1000000





          share|improve this answer
































            2














            I think this can be greatly simplified,



            for i in $(seq 0 24); do
            printf "$(($i * 40000 + 1)) $((($i+1) * 40000))n";
            done;

            1 40000
            40001 80000
            80001 120000
            120001 160000
            160001 200000
            200001 240000
            240001 280000
            280001 320000
            320001 360000
            360001 400000
            400001 440000
            440001 480000
            480001 520000
            520001 560000
            560001 600000
            600001 640000
            640001 680000
            680001 720000
            720001 760000
            760001 800000
            800001 840000
            840001 880000
            880001 920000
            920001 960000
            960001 1000000





            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',
              autoActivateHeartbeat: false,
              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%2f494309%2fhow-do-i-generate-a-sequence-of-numbers-like-this%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              4














              Output the sequence "manually" using



              i=0
              while [ "$i" -lt 1000000 ]; do
              printf '%d %dn' "$(( i+1 ))" "$(( i += 40000 ))"
              done


              or



              for (( i = 1; i < 1000000; i += 40000 )); do
              printf '%d %dn' "$i" "$(( i + 39999 ))"
              done


              or something like it.



              Or paste together two separate sequences from seq:



              $ paste <( seq 1 40000 1000000 ) <( seq 40000 40000 1000000 )
              1 40000
              40001 80000
              80001 120000
              120001 160000
              160001 200000
              200001 240000
              240001 280000
              280001 320000
              320001 360000
              360001 400000
              400001 440000
              440001 480000
              480001 520000
              520001 560000
              560001 600000
              600001 640000
              640001 680000
              680001 720000
              720001 760000
              760001 800000
              800001 840000
              840001 880000
              880001 920000
              920001 960000
              960001 1000000


              Suggested by JdeBP in comments:



              jot - 1 1000000 40000 | awk ' print $1, $1+39999 '


              but it's essentially the same as the second loop at the top, and since seq is more readily available on Linux machines (jot is originally a BSD utility, while seq is part of GNU coreutils), and the most common visitor here is a Linux user, and the question was tagged with seq, it may be more usefully written as



              seq 1 40000 1000000 | awk ' print $1, $1+39999 '





              share|improve this answer

























              • Don't forget the option of piping jot into awk. (-:

                – JdeBP
                Jan 13 at 21:36











              • Yeah, and you should also put a cat (or two tac(1)s) between jot and awk.

                – mosvy
                Jan 13 at 21:55












              • @mosvy A cat in a pipeline is (often) a sad cat.

                – Kusalananda
                Jan 13 at 22:01
















              4














              Output the sequence "manually" using



              i=0
              while [ "$i" -lt 1000000 ]; do
              printf '%d %dn' "$(( i+1 ))" "$(( i += 40000 ))"
              done


              or



              for (( i = 1; i < 1000000; i += 40000 )); do
              printf '%d %dn' "$i" "$(( i + 39999 ))"
              done


              or something like it.



              Or paste together two separate sequences from seq:



              $ paste <( seq 1 40000 1000000 ) <( seq 40000 40000 1000000 )
              1 40000
              40001 80000
              80001 120000
              120001 160000
              160001 200000
              200001 240000
              240001 280000
              280001 320000
              320001 360000
              360001 400000
              400001 440000
              440001 480000
              480001 520000
              520001 560000
              560001 600000
              600001 640000
              640001 680000
              680001 720000
              720001 760000
              760001 800000
              800001 840000
              840001 880000
              880001 920000
              920001 960000
              960001 1000000


              Suggested by JdeBP in comments:



              jot - 1 1000000 40000 | awk ' print $1, $1+39999 '


              but it's essentially the same as the second loop at the top, and since seq is more readily available on Linux machines (jot is originally a BSD utility, while seq is part of GNU coreutils), and the most common visitor here is a Linux user, and the question was tagged with seq, it may be more usefully written as



              seq 1 40000 1000000 | awk ' print $1, $1+39999 '





              share|improve this answer

























              • Don't forget the option of piping jot into awk. (-:

                – JdeBP
                Jan 13 at 21:36











              • Yeah, and you should also put a cat (or two tac(1)s) between jot and awk.

                – mosvy
                Jan 13 at 21:55












              • @mosvy A cat in a pipeline is (often) a sad cat.

                – Kusalananda
                Jan 13 at 22:01














              4












              4








              4







              Output the sequence "manually" using



              i=0
              while [ "$i" -lt 1000000 ]; do
              printf '%d %dn' "$(( i+1 ))" "$(( i += 40000 ))"
              done


              or



              for (( i = 1; i < 1000000; i += 40000 )); do
              printf '%d %dn' "$i" "$(( i + 39999 ))"
              done


              or something like it.



              Or paste together two separate sequences from seq:



              $ paste <( seq 1 40000 1000000 ) <( seq 40000 40000 1000000 )
              1 40000
              40001 80000
              80001 120000
              120001 160000
              160001 200000
              200001 240000
              240001 280000
              280001 320000
              320001 360000
              360001 400000
              400001 440000
              440001 480000
              480001 520000
              520001 560000
              560001 600000
              600001 640000
              640001 680000
              680001 720000
              720001 760000
              760001 800000
              800001 840000
              840001 880000
              880001 920000
              920001 960000
              960001 1000000


              Suggested by JdeBP in comments:



              jot - 1 1000000 40000 | awk ' print $1, $1+39999 '


              but it's essentially the same as the second loop at the top, and since seq is more readily available on Linux machines (jot is originally a BSD utility, while seq is part of GNU coreutils), and the most common visitor here is a Linux user, and the question was tagged with seq, it may be more usefully written as



              seq 1 40000 1000000 | awk ' print $1, $1+39999 '





              share|improve this answer















              Output the sequence "manually" using



              i=0
              while [ "$i" -lt 1000000 ]; do
              printf '%d %dn' "$(( i+1 ))" "$(( i += 40000 ))"
              done


              or



              for (( i = 1; i < 1000000; i += 40000 )); do
              printf '%d %dn' "$i" "$(( i + 39999 ))"
              done


              or something like it.



              Or paste together two separate sequences from seq:



              $ paste <( seq 1 40000 1000000 ) <( seq 40000 40000 1000000 )
              1 40000
              40001 80000
              80001 120000
              120001 160000
              160001 200000
              200001 240000
              240001 280000
              280001 320000
              320001 360000
              360001 400000
              400001 440000
              440001 480000
              480001 520000
              520001 560000
              560001 600000
              600001 640000
              640001 680000
              680001 720000
              720001 760000
              760001 800000
              800001 840000
              840001 880000
              880001 920000
              920001 960000
              960001 1000000


              Suggested by JdeBP in comments:



              jot - 1 1000000 40000 | awk ' print $1, $1+39999 '


              but it's essentially the same as the second loop at the top, and since seq is more readily available on Linux machines (jot is originally a BSD utility, while seq is part of GNU coreutils), and the most common visitor here is a Linux user, and the question was tagged with seq, it may be more usefully written as



              seq 1 40000 1000000 | awk ' print $1, $1+39999 '






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jan 13 at 21:39

























              answered Jan 13 at 21:25









              KusalanandaKusalananda

              127k16239393




              127k16239393












              • Don't forget the option of piping jot into awk. (-:

                – JdeBP
                Jan 13 at 21:36











              • Yeah, and you should also put a cat (or two tac(1)s) between jot and awk.

                – mosvy
                Jan 13 at 21:55












              • @mosvy A cat in a pipeline is (often) a sad cat.

                – Kusalananda
                Jan 13 at 22:01


















              • Don't forget the option of piping jot into awk. (-:

                – JdeBP
                Jan 13 at 21:36











              • Yeah, and you should also put a cat (or two tac(1)s) between jot and awk.

                – mosvy
                Jan 13 at 21:55












              • @mosvy A cat in a pipeline is (often) a sad cat.

                – Kusalananda
                Jan 13 at 22:01

















              Don't forget the option of piping jot into awk. (-:

              – JdeBP
              Jan 13 at 21:36





              Don't forget the option of piping jot into awk. (-:

              – JdeBP
              Jan 13 at 21:36













              Yeah, and you should also put a cat (or two tac(1)s) between jot and awk.

              – mosvy
              Jan 13 at 21:55






              Yeah, and you should also put a cat (or two tac(1)s) between jot and awk.

              – mosvy
              Jan 13 at 21:55














              @mosvy A cat in a pipeline is (often) a sad cat.

              – Kusalananda
              Jan 13 at 22:01






              @mosvy A cat in a pipeline is (often) a sad cat.

              – Kusalananda
              Jan 13 at 22:01














              4














              Enjoy a single AWK expression :)



              awk 'BEGIN while (c < 1000000) print (++c, c += 39999) '



              • ++c - pre increment variable

              The output:



              1 40000
              40001 80000
              80001 120000
              120001 160000
              160001 200000
              200001 240000
              240001 280000
              280001 320000
              320001 360000
              360001 400000
              400001 440000
              440001 480000
              480001 520000
              520001 560000
              560001 600000
              600001 640000
              640001 680000
              680001 720000
              720001 760000
              760001 800000
              800001 840000
              840001 880000
              880001 920000
              920001 960000
              960001 1000000





              share|improve this answer





























                4














                Enjoy a single AWK expression :)



                awk 'BEGIN while (c < 1000000) print (++c, c += 39999) '



                • ++c - pre increment variable

                The output:



                1 40000
                40001 80000
                80001 120000
                120001 160000
                160001 200000
                200001 240000
                240001 280000
                280001 320000
                320001 360000
                360001 400000
                400001 440000
                440001 480000
                480001 520000
                520001 560000
                560001 600000
                600001 640000
                640001 680000
                680001 720000
                720001 760000
                760001 800000
                800001 840000
                840001 880000
                880001 920000
                920001 960000
                960001 1000000





                share|improve this answer



























                  4












                  4








                  4







                  Enjoy a single AWK expression :)



                  awk 'BEGIN while (c < 1000000) print (++c, c += 39999) '



                  • ++c - pre increment variable

                  The output:



                  1 40000
                  40001 80000
                  80001 120000
                  120001 160000
                  160001 200000
                  200001 240000
                  240001 280000
                  280001 320000
                  320001 360000
                  360001 400000
                  400001 440000
                  440001 480000
                  480001 520000
                  520001 560000
                  560001 600000
                  600001 640000
                  640001 680000
                  680001 720000
                  720001 760000
                  760001 800000
                  800001 840000
                  840001 880000
                  880001 920000
                  920001 960000
                  960001 1000000





                  share|improve this answer















                  Enjoy a single AWK expression :)



                  awk 'BEGIN while (c < 1000000) print (++c, c += 39999) '



                  • ++c - pre increment variable

                  The output:



                  1 40000
                  40001 80000
                  80001 120000
                  120001 160000
                  160001 200000
                  200001 240000
                  240001 280000
                  280001 320000
                  320001 360000
                  360001 400000
                  400001 440000
                  440001 480000
                  480001 520000
                  520001 560000
                  560001 600000
                  600001 640000
                  640001 680000
                  680001 720000
                  720001 760000
                  760001 800000
                  800001 840000
                  840001 880000
                  880001 920000
                  920001 960000
                  960001 1000000






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 13 at 21:59

























                  answered Jan 13 at 21:52









                  RomanPerekhrestRomanPerekhrest

                  23k12447




                  23k12447





















                      2














                      I think this can be greatly simplified,



                      for i in $(seq 0 24); do
                      printf "$(($i * 40000 + 1)) $((($i+1) * 40000))n";
                      done;

                      1 40000
                      40001 80000
                      80001 120000
                      120001 160000
                      160001 200000
                      200001 240000
                      240001 280000
                      280001 320000
                      320001 360000
                      360001 400000
                      400001 440000
                      440001 480000
                      480001 520000
                      520001 560000
                      560001 600000
                      600001 640000
                      640001 680000
                      680001 720000
                      720001 760000
                      760001 800000
                      800001 840000
                      840001 880000
                      880001 920000
                      920001 960000
                      960001 1000000





                      share|improve this answer



























                        2














                        I think this can be greatly simplified,



                        for i in $(seq 0 24); do
                        printf "$(($i * 40000 + 1)) $((($i+1) * 40000))n";
                        done;

                        1 40000
                        40001 80000
                        80001 120000
                        120001 160000
                        160001 200000
                        200001 240000
                        240001 280000
                        280001 320000
                        320001 360000
                        360001 400000
                        400001 440000
                        440001 480000
                        480001 520000
                        520001 560000
                        560001 600000
                        600001 640000
                        640001 680000
                        680001 720000
                        720001 760000
                        760001 800000
                        800001 840000
                        840001 880000
                        880001 920000
                        920001 960000
                        960001 1000000





                        share|improve this answer

























                          2












                          2








                          2







                          I think this can be greatly simplified,



                          for i in $(seq 0 24); do
                          printf "$(($i * 40000 + 1)) $((($i+1) * 40000))n";
                          done;

                          1 40000
                          40001 80000
                          80001 120000
                          120001 160000
                          160001 200000
                          200001 240000
                          240001 280000
                          280001 320000
                          320001 360000
                          360001 400000
                          400001 440000
                          440001 480000
                          480001 520000
                          520001 560000
                          560001 600000
                          600001 640000
                          640001 680000
                          680001 720000
                          720001 760000
                          760001 800000
                          800001 840000
                          840001 880000
                          880001 920000
                          920001 960000
                          960001 1000000





                          share|improve this answer













                          I think this can be greatly simplified,



                          for i in $(seq 0 24); do
                          printf "$(($i * 40000 + 1)) $((($i+1) * 40000))n";
                          done;

                          1 40000
                          40001 80000
                          80001 120000
                          120001 160000
                          160001 200000
                          200001 240000
                          240001 280000
                          280001 320000
                          320001 360000
                          360001 400000
                          400001 440000
                          440001 480000
                          480001 520000
                          520001 560000
                          560001 600000
                          600001 640000
                          640001 680000
                          680001 720000
                          720001 760000
                          760001 800000
                          800001 840000
                          840001 880000
                          880001 920000
                          920001 960000
                          960001 1000000






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 13 at 21:41









                          Evan CarrollEvan Carroll

                          5,499104381




                          5,499104381



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Unix & Linux Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494309%2fhow-do-i-generate-a-sequence-of-numbers-like-this%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown






                              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