Splitting up a too-wide text file
Jonathan I. Kamens
jik at athena.mit.edu
Fri Mar 15 12:32:43 AEST 1991
Um, I thought it would be obvious that you use the programs I mentioned in
order to create a new file containing the portions of the lines that you want
printed on separate pages, and then print out that file.
Now, if you want the "continuation pages" to appear right after their
corresponding pages in the original file, then you can write a script to
process the files sixty lines at a time (or however many lines fit on a page)
and write out a new file containing two pages for each original page.
If that's really what you want to do, then perhaps perl *isn't* overkill,
because it will allow you to do this more easily than any other other
utilities I mentioned.
I guess you could go through contortions to get sed and awk to keep enough
state to be able to write out a whole page in one glob and then the right side
of that page immediately afterward. With sed, I would print the first part of
each line as I encountered it, adding the second page to the hold space, and
then print the hold space and clear it at the end of every sixty lines. With
awk, I would do pretty much the same thing, but I would keep the second page
constructed thus far in a variable, not the hold space (which awk doesn't
have).
If the sed hold space is limited in length, you lose. If the length of a
string variable in awk is limited in length, you lose, or you can use an array
to store each line of the second page rather than storing it in one string.
In either case, I think perl would be easier, if you know perl.
--
Jonathan Kamens USnail:
MIT Project Athena 11 Ashford Terrace
jik at Athena.MIT.EDU Allston, MA 02134
Office: 617-253-8085 Home: 617-782-0710
More information about the Comp.unix.questions
mailing list