[comp.unix.wizards] AWK question

lesh@BRL.ARPA (01/26/87)

	I would like to use 'awk' to segregate data from a master file
into specific files with the filename based on the contents of a
specific field in one of the input records.  'awk' permits directing printed
output to filenames specified in quoted variables.

	"Without quotes, the file names are treated as uninitialized
variables and all output then goes to the same file."*1  Unquoted variables
thus provide the vehicle to files named from a value obtained from a field
of a previous record.

	THE PROBLEM:
	"Users should also note that there is an upper limit to the
number of files that are written in this way.  At present it is ten."*1

	I can't find any way to close a file opened by 'awk' and very
soon get the "too many opened files error message". 

	Any suggestions?

	
1. Support Tools Guide, p. 6-31.

pdg@ihdev.UUCP (01/27/87)

In article <3747@brl-adm.ARPA> lesh@BRL.ARPA (ISC | howard) writes:
>	THE PROBLEM:
>	"Users should also note that there is an upper limit to the
>number of files that are written in this way.  At present it is ten."*1
>
>	I can't find any way to close a file opened by 'awk' and very
>soon get the "too many opened files error message". 
>
>	Any suggestions?
>
>	
>1. Support Tools Guide, p. 6-31.


Any version of awk produced after July '85 (when my documentation says
this feature was added, has the 'close' function.  The close function
is used as follows:

close("filename");

where filename is the name of a file or pipe that has been previously
opened.

I just tried it and it worked with no problems.  Unfortunately, most
awks are not this new, and there does not seem to be a way to accomplish
this on those earlier awks.

-- 

Paul Guthrie
ihnp4!ihdev!pdg			This Brain left intentionally blank.

guy@gorodish.UUCP (01/29/87)

>Any version of awk produced after July '85 (when my documentation says
>this feature was added, has the 'close' function.

And which "awk"s are those?  I can't seem to find it in the S5R3
source we have here.  Is this part of the new Research "awk", with
functions and all those wonderful things?