The following awk program would produce two "rulers", each consisting of a line of digits. The second line will be numbered from 1 to 10 (with 0 taking the place of 10) with no intermediate spacing between the digits. The first line will be numbered in the same way, but with some spacing between each digit.
The program takes two optional command-line arguments. The first argument is the total width of the second ruler (80 by default), while the second argument is the step size, or tab width, of the numbering of the first ruler (8 by default, as this is the common tab width on Unix terminals).
Example runs:
$ ./script 1 2 3 4 5 6 7 8 9 0 12345678901234567890123456789012345678901234567890123456789012345678901234567890 $ ./script 72 1 2 3 4 5 6 7 8 9 123456789012345678901234567890123456789012345678901234567890123456789012 $ ./script 72 10 1 2 3 4 5 6 7 123456789012345678901234567890123456789012345678901234567890123456789012 $ ./script 122 6 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
Script:
#!/usr/bin/awk -f BEGIN { width = ARGC >= 2 ? ARGV[1] : 80 step = ARGC >= 3 ? ARGV[2] : 8 while (++i <= width) { if (i%step == 0) line1 = line1 sprintf("%*s", step, (i/step)%10) line2 = line2 (i%10) } print line1 print line2 }