#! /bin/sh # # run-books [...] # # Run a "book" of files through a specific troff command, and get the # page numbers right. Outputs a list of # filename startpage # pairs to stdout, and leaves the postscript of each file in # .ps. # # The troff command should end in troff, and include a pipeline with # whatever preprocessors are necessary. case $# in 0|1) echo "$0: too few arguments"; exit 1;; esac tcmd=$1; shift curpage=1 for i in "$@"; do # Format the file echo "$i $curpage" cat $i | eval $tcmd -n$curpage | psdit > $i.ps curpage=`egrep "^%%Page:" $i.ps | tail -1 | awk '{print $2}'` curpage=`expr $curpage + 1` done