tmp> time ruby sampling.rb 5_000_000 1_000_000_000 >big_sample.txt

real    2m36.816s
user    0m0.010s
sys     0m0.000s
tmp> head big_sample.txt
221
248
508
769
776
857
1186
1395
1434
1868
tmp> tail big_sample.txt
999997722
999998019
999998183
999998422
999998885
999998919
999999068
999999338
999999660
999999806

Jim
-- 
Jim Menard, jimm / io.com, http://www.io.com/~jimm
Dash dash space newline
Four-line witty quotation
Perfect message end
     -- Donald Welsh in rec.humor.oracle.d