phil (05/02/83)
Every need to generate a quick and dirty table of contents for a ms document and not want to hack up the macro? Well I recently needed to and in 20 minutes came up with a reasonable solution. Run the following on a standard nroff -ms output and watch the results. It is not perfect and can be fooled by some tables but they are easy to edit out. It also assumes your document starts at page 1. Enjoy.. #! /bin/sh # /usr/local/toc # Table of Contents generator for ms macro package. # uucp: sequel!phil, Phil Hochstetler 4.30.83 # cat $@ | sed 's/_//g' | \ awk ' BEGIN { printf " Table Of Contents\n" printf " " printf " Page\n" PAGE = 1 } /- [0-9]+ -/ \ { PAGE++ } /^[ ]+([1-9][1-9]*\.)+[ ]+/\ { line = sprintf ("%s%s", $0, \ "............................................................") printf "%.60s %3d\n", line, PAGE }'