How do I generate a sequence of numbers like this?
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
New contributor
add a comment |
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
New contributor
add a comment |
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
New contributor
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
bash seq
New contributor
New contributor
edited Jan 13 at 21:23
Seqeur
New contributor
asked Jan 13 at 21:18
SeqeurSeqeur
133
133
New contributor
New contributor
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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 }'
Don't forget the option of pipingjot
intoawk
. (-:
– JdeBP
Jan 13 at 21:36
Yeah, and you should also put acat
(or twotac(1)
s) betweenjot
andawk
.
– mosvy
Jan 13 at 21:55
@mosvy A cat in a pipeline is (often) a sad cat.
– Kusalananda
Jan 13 at 22:01
add a comment |
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
add a comment |
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
add a comment |
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
});
}
});
Seqeur is a new contributor. Be nice, and check out our Code of Conduct.
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
Required, but never shown
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
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 }'
Don't forget the option of pipingjot
intoawk
. (-:
– JdeBP
Jan 13 at 21:36
Yeah, and you should also put acat
(or twotac(1)
s) betweenjot
andawk
.
– mosvy
Jan 13 at 21:55
@mosvy A cat in a pipeline is (often) a sad cat.
– Kusalananda
Jan 13 at 22:01
add a comment |
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 }'
Don't forget the option of pipingjot
intoawk
. (-:
– JdeBP
Jan 13 at 21:36
Yeah, and you should also put acat
(or twotac(1)
s) betweenjot
andawk
.
– mosvy
Jan 13 at 21:55
@mosvy A cat in a pipeline is (often) a sad cat.
– Kusalananda
Jan 13 at 22:01
add a comment |
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 }'
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 }'
edited Jan 13 at 21:39
answered Jan 13 at 21:25
KusalanandaKusalananda
124k16236388
124k16236388
Don't forget the option of pipingjot
intoawk
. (-:
– JdeBP
Jan 13 at 21:36
Yeah, and you should also put acat
(or twotac(1)
s) betweenjot
andawk
.
– mosvy
Jan 13 at 21:55
@mosvy A cat in a pipeline is (often) a sad cat.
– Kusalananda
Jan 13 at 22:01
add a comment |
Don't forget the option of pipingjot
intoawk
. (-:
– JdeBP
Jan 13 at 21:36
Yeah, and you should also put acat
(or twotac(1)
s) betweenjot
andawk
.
– 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
add a comment |
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
add a comment |
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
add a comment |
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
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
edited Jan 13 at 21:59
answered Jan 13 at 21:52
RomanPerekhrestRomanPerekhrest
23k12346
23k12346
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Jan 13 at 21:41
Evan CarrollEvan Carroll
5,399104380
5,399104380
add a comment |
add a comment |
Seqeur is a new contributor. Be nice, and check out our Code of Conduct.
Seqeur is a new contributor. Be nice, and check out our Code of Conduct.
Seqeur is a new contributor. Be nice, and check out our Code of Conduct.
Seqeur is a new contributor. Be nice, and check out our Code of Conduct.
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.
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
Required, but never shown
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
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
Required, but never shown
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
Required, but never shown
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
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