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:
```shell
$ ./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:
```awk
#!/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.