Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcsun!hp4nl!ruuinf!piet From: piet@cs.ruu.nl (Piet van Oostrum) Newsgroups: comp.unix.questions Subject: Re: ``Stupid awk'' question Message-ID: <1684@ruuinf.cs.ruu.nl> Date: 11 Oct 89 15:58:38 GMT References: Sender: news@ruuinf.cs.ruu.nl Reply-To: piet@cs.ruu.nl (Piet van Oostrum) Distribution: comp Organization: Dept of Computer Science, University of Utrecht, Holland Lines: 35 In-reply-to: dmaustin@vivid.sun.com (Darren Austin) In article , dmaustin@vivid (Darren Austin) writes: `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 ` `so apparently it is running out of file descriptors. I thought `that would be taken care of by using the "close" function. Am I `using it incorrectly, or am I doing something else wrong? Is I've never heard of close. That must be one of those modern things. `there a better way to do this with other tools? ` 1. Let awk generate a shell script, and run that through sh. (current == $2) {print} (current != $2) {if (current) print "Some-funny-eof-sequence"; current=$2; print "cat << Some-funny-eof-sequence >>"current".summary";} END { print "Some-funny-eof-sequence"} 2. Use Larry Wall's perl. -- Piet van Oostrum, Dept of Computer Science, University of Utrecht Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. Telephone: +31-30-531806 Internet: piet@cs.ruu.nl Telefax: +31-30-513791 Uucp: uunet!mcsun!hp4nl!ruuinf!piet