Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Too many files open

Status
Not open for further replies.

malpa

Technical User
Feb 8, 2004
122
CO
Hi


I have approximately 62000 files. My program stops after only processing 285 files. The error message is "too many files open".

Question?
Is not enough the command close (cmd) to close the previous file???


BEGIN{FS=";"
while ((getline < "List_files_Feb.txt") > 0){
j++
files[j]=$1
fe[j]=sprintf("%0+2s",$3)
}
close("List_files_Feb.txt")

for ( j=1; j in files ; j++ )
{
r = ini""files[j]
print r" - "j
if ( r ~ /.Z$/ ){
cmd = "zcat " r
}
else{
cmd ="cat " r}
while( cmd | getline var ) {
print var >> fin"T33.a"substr(var,111,6)".a"fe[j]
}
close (cmd)

}
}'


Thanks malpa
 
This code is also opening a file which you may need to close:

[tt]print var >> fin"T33.a"substr(var,111,6)".a"fe[j][/tt]

I suggest:

[tt]outfile=fin"T33.a"substr(var,111,6)".a"fe[j]
print var >> outfile
close(outfile)[/tt]

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top