Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!spool.mu.edu!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: Splitting up a too-wide text file Message-ID: <1991Mar15.023243.20966@athena.mit.edu> Date: 15 Mar 91 02:32:43 GMT References: <1991Mar15.003416.16893@athena.mit.edu> <1991Mar15.012231.7048@convex.com> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 34 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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710