Home > Software engineering >  Generating numbers sequence containing leading zeros
Generating numbers sequence containing leading zeros

Time:10-27

I'm looking for a way to create a sequence of numbers with a number of leading zeros.

For example, starting from 00000001 to 1000000000.

I tried many variations of seq but I was never able to produce a sequence with starting number as indicated to go to the desired end number.

To generate a billion of numbers, seq would likely take 20min on my machine o printf which is a ton slower is likely not an option, I'm looking into achieving this with seq only for starters if possible.

Any ideas?

CodePudding user response:

To generate a sequence with a specified format you have to use -f argument like this:

seq -f "g" 1000000000

Although you didn't specify how you want to use so large numbers it would be better to parallelize it to make a final solution efficient.

  • Related