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.
Output the sequence "manually" using
i=0
while [ "$i" -lt 1000000 ]; do
printf '%d %d\n' "$(( i+1 ))" "$(( i += 40000 ))"
done
or
for (( i = 1; i < 1000000; i += 40000 )); do
printf '%d %d\n' "$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 }'
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments