Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!usc!snorkelwacker!bloom-beacon!spdcc!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.unix.questions Subject: Re: Stupid awk question Message-ID: <720@lakart.UUCP> Date: 16 Oct 89 21:24:49 GMT References: Distribution: comp Organization: Lakart Corporation, Newton, MA Lines: 31 dmaustin@vivid.sun.com (Darren Austin) sez: > Hi all, > I am trying to split up a large output file into several > smaller files. The smaller files are named after the value in > the second field. I tried using the following simple awk script, > > (current == $2) {print > current".summary"} > (current != $2) {close(current".summary");current=$2;print > current".summary";} > > but it fails with > > awk: too many output files 10 Try this: ------------------------------------------- #! /bin/sh awk '{ print "echo '"'"'" $0 "'"'"' >> " $2 ".summary" }' | sh ------------------------------------------- Only problem is, it tends to chew up process id's. Oh well ..... Also it appends, so you might have a problem if you wanted to initialise at the start of each run. But you get the general idea. Also has the advantage of not getting into trouble if your input file hasn't been sorted (i.e. $2 records can come in any order) -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+