I want to enumerate numbers (between 1 to 10136 range) but so far, most tools and trick I tried would struggle after 109 numbers or so...
Here some examples (with smaller range):
For seq 99999
real 0m0.056s
user 0m0.004s
sys 0m0.051s
For seq 9999999
real 1m5.550s
user 0m0.156s
sys 0m6.615s
So on so forth... Thing is, it start to struggle only after the 9th number or so (in this case, 999999999) and on ward. I thought of splitting them in smaller range and running them in parallel:
cat <(seq 000 999) <(seq 999 1999) <(seq 1999 2999) <(seq 2999 3999) <(seq 3999 4999) <(seq 4999 5999) <(seq 5999 6999) <(seq 6999 7999) <(seq 7999 8999) <(seq 8999 9999) <(seq 9999 10999) <(seq 10999 11999) <(seq 11999 12999) <(seq 12999 13999) <(seq 13999 14999)
real 0m0.258s
user 0m0.008s
sys 0m0.908s
which is considerably slower (especially with bigger range as it goes on) than
seq 000 14999
real 0m0.042s
user 0m0.000s
sys 0m0.041s
I tried a perl script i found on SO:
#!/usr/bin/perl
use strict;
if ( ($#ARGV+1)!=2 ) { print "usage $0 \n"; }
my @r = &bitfizz( $ARGV[0], $ARGV[1] );
for(@r){ print "$_\n"; }
sub bitfizz() {
$_[0]=join( ",", split(//, $_[0] ) );
for( my $i=1; $i<=$_[1]; $i+=1 ) { $_=$_."{$_[0]}"; }
@r=glob( $_ );
}
with perl script.pl "0123456789" 10*
But while it seemed faster than seq (when doing anything less than 1010), it still struggle and seems like it would take forever to complete...
I don't need to write the enumerated numbers to a file, but i do need it to be on stdout, so that i can process it.
EDIT:
@Isaac mentioned in his answer (and in the comment) something that could work, and while it does goes through 1010 much faster than anything else mentioned, it still struggle for any range bigger than 1010 (and by extension, 10136).
Worth mentioning since it was mentioned as a possible duplicate to this post (which it technically isn't).
How do i enumerate from 0 to 10136 faster than GNU seq does?
1
. Using thecalc
arbintrary precision calculator to increment by10^130
completes in about a minute:calc 't=10^136; i=10^130; for (f=1; f <= t; f=f+i) { print f; }'
; this prints to STDOUT, and can be piped, etc. Appending a| wc
to the end shows the output is 1000000 lines, and 136888760 chars long. (For less monotonous output try changing10^130
to86!
.)