#!/bin/sh # lwpage -- select pages from a PostScript file # Copyright (c) 1986 by Pipeline Associates, Inc. # Version 1.0 if [ $# -lt 2 ] then echo " Usage: $0 file pages... pages is a page number or list of numbers. pages must be ordered! Example: $0 lw.out 1 7-10 99 " exit fi file=$1 if [ "x$file" = x- ] then file="" fi shift cmdlist=":cont 1,/^%%EndProlog/p; /^%%MoreProlog/,/^%%EndMoreProlog/{; p; b }; " for arg do case "$arg" in [0-9]*-[0-9]*) start=`echo $arg | cut -f1 -d-` end=`echo $arg | cut -f2 -d-` end=`expr $end + 1`;; [0-9]*) start=$arg end=`expr $start + 1`;; *) echo "bad page number: $arg" exit;; esac cmdlist="$cmdlist /^%%Page: $start /,/^%%Page: $end /p"; done cmdlist="$cmdlist; /^%%Page: $end /q" sed -n "$cmdlist" $file