2

I'm trying to generate a huge list of sequenced numbers with 0 padding

 for example:
 00000000
 00000001
 00000002
 .
 .
 99999997
 99999998
 99999999

im trying something like:

 for i in $(seq 00000000 99999999);do echo ${i} >> filelist.txt;done

this has two problems.

 1: the range is too big and the system cant handle it
 2: the numbers arent padded so I end up with something like this:

 1
 2
 3
 .
 .
 998
 999
 1000

Any help would be greatly appreciated..

Almus
  • 23
  • 3

2 Answers2

4

seq already knows how to do padding.

seq -w 00000000 00000009 >filelist.txt

There's also -f for more general formats (mostly useful when the increment isn't an integer). For more complex output, the best solution would be to postprocess the output of seq with sed or other text processing tools.

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
0

How about doing this in 2 steps

seq 10 > file

while read i; do printf "%.8d\n" $i; done < file
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
00000009
00000010
Fredrik Pihl
  • 44,604
  • 7
  • 83
  • 130