Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.unix.questions Subject: Re: Splitting up a too-wide text file Message-ID: <1991Mar15.023627.23448@jpl-devvax.jpl.nasa.gov> Date: 15 Mar 91 02:36:27 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 40 In article thomson@zazen.macc.wisc.edu (Don Thomson) writes: : I've got a file of ASCII text that has lines that are too long to easily : print, formatted in columns. I'd like to run the file through a filter that : will essentially break each page in half horizontally at a column break and : place the right-hand side of the broken-off text on a new following page, : resulting in a new file of reasonable width. I've got a few relatively : inelegant solutions in mind, but am interested in suggestions on how other : people might approach the problem with an appropriate combination of UNIX : tools. Any ideas? The sed/cut/colrm solutions are okay unless you really do want the pages to alternate, in which case you'll have to program it somehow. I wouldn't try to program it in shell, though it's certainly possible. Here's a crack at in (of all things) Perl. :-) #!/usr/bin/perl $LINES = 55; # put 55 lines on a page $TEMPLATE = 'A80A*'; # split after 80 columns while (<>) { chop; ($a,$b) = unpack($TEMPLATE, $_); push(@a, $a . "\n"); push(@b, $b . "\n"); &dopage if @a >= $LINES; } &dopage if @a; sub dopage { print @a, "\f", @b, "\f"; @a = @b = (); } I suppose this could be generalized to print n pages up. Overkill, eh? Larry Wall lwall@jpl-devvax.jpl.nasa.gov