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 similarly 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:
$ ./ruler 1 2 3 4 5 6 7 8 9 0 12345678901234567890123456789012345678901234567890123456789012345678901234567890 $ ./ruler 72 1 2 3 4 5 6 7 8 9 123456789012345678901234567890123456789012345678901234567890123456789012 $ ./ruler 72 10 1 2 3 4 5 6 7 123456789012345678901234567890123456789012345678901234567890123456789012 $ ./ruler 122 6 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
The ruler 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 }
This essentially adds the next digit to the line2 string (the second ruler) in each iteration of the while loop, while adding a right-adjusted field of width step with a digit to the line1 string (the first ruler) every step iteration.
There is no width restriction in this code, and no sanitation or validation of the command line arguments.
l=0+9+8+7+6+5+4+3+2+1+ l=$l$l$l l=${l//+/-+-} l=${l//-/....}echo " "{1..7}(8 spaces, echo will add the 9th)length=72 ruler=yourcode ruler="${ruler::$length}", with a ruler of ample length.