As is stated in the comments, sed -ne 42,99p
will copy lines 42–99 (inclusive) from its input to its output. That is assuming you're on some sort of unix (though I suppose you can have sed on windows too). You can do this in a script or a makefile, putting the result in a temporary file that you include.
Alternatively, assuming you are on unix, you can resort to some mild unix wizardry: Say the TeX file you want to include part of, is named foo.tex
. Then you can do
mkfifo foosnips.tex
while sed -ne 42,99p foo.tex > foosnips.tex || [ $? == 141 ]; do sleep 1; done &
(modify for your shell if it's not (ba)sh) and then input foosnips
in your master TeX file. Each time you TeX it, the sed command will extract the requested lines. The background job should keep on running until you reboot the computer, but thanks to the way fifos work, it will not actually do anything until the fifo is opened for reading. Kill it by hand when it is no longer needed, or if you need to adjust the parameters.
Doing it that way is perhaps not worth it, unless foo.tex
changes very often, or the extract is very large and you don't want to keep it as a separate file.
(The test for exit status 141 (128+13, where 13 is the signal number of the PIPE signal) is there to make sure the loop is not terminated if you read only part of the output from the fifo, as when TeX is quit due to some error. And the sleep is needed to make sure the process at the receiving end of the fifo has a chance to close the file before a new sed process starts.)
sed -n 'x,yp file
to a temporary file and input that. (where x and y are start and end lines respectively)sed -ne 42,99p
will copy lines 42–99 (inclusive) of its input to its output.