Advertisement

05.29.2006 at 12:12AM PDT, ID: 21866921
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

Nawk outputing the error: "nawk: FILENAME makes too many open files"

Asked by glennstewart in Unix Systems Programming

Tags: , , , ,

Hi All,

For some background this question has the following PAQ's leading up to this point.
This question isn't so much about how to refine the awk script, rather than to determine how best to work with large files.

The file I am testing gets broken into 30+ files, but breaks at the 20 mark. If you're interested in the input in order to answer the question, please review the following PAQ's.

http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_21763311.html
http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_21764891.html
And most recently:
http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_21854851.html

----------------------------------------------------------------------

SCRIPT EXPLANATION:
===============

The current nawk is formatted:

=================================================
nawk -F| -v Footer= BEGIN{f="/dev/null"; oldfile = f}
                /^\|\|/{
                        c++
                        f=sprintf("%s%s'$DateTime'%03d.DHR",$3,$4,c)
                        print Footer >> oldfile
                        oldfile = f
                       }

                       { print >> f }
                END { print Footer >> oldfile }
                FILENAME
=================================================

Where the files being created look like:

AU402679060529.1643001.DHR
AU414381060529.1643002.DHR
AU420252060529.1643003.DHR
AU423247060529.1643004.DHR
<etc....>

Or general format:
XX123456YYMMDD.HHMM???.DHR
Where:
XX => Comes from the file delimiter
123456 => Comes from the delimiter
YYMMDD.HHMM => Comes from a variable $DateTime

In addition:
* the variable $Footer contains some text to be inserted at the end of each file.
* The delimiter is || where example is ||XX|123456|blah|blah|blah|blah
* /dev/null is used to ensure all text in input file before the first "||" is ignored

ERROR MESSAGE AS IT APPEAR:
=====================

This currently appears upon execution of a large input file (from ksh -x output):

=================================================
+ nawk -F| -v Footer= BEGIN{f="/dev/null"; oldfile = f}
                /^\|\|/{
                        c++
                        f=sprintf("%s%s060529.1639%03d.DHR",$3,$4,c)
                        print Footer >> oldfile
                        oldfile = f
                       }

                       {print >> f }
                END { print Footer >> oldfile}

                /directory/filename
nawk: AU451922060529.1639020.DHR makes too many open files
 input record number 7676, file /directory/filename
 source line number 9
=================================================

QUESTIONS:

Q: How can this error be avoided?
Q: Is there a more efficient way to deal with large files?


Thanks in advance,

GlennStart Free Trial
[+][-]05.29.2006 at 12:14AM PDT, ID: 16782453

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2006 at 03:14AM PDT, ID: 16783277

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Unix Systems Programming
Tags: many, open, too, nawk, files
Sign Up Now!
Solution Provided By: ahoffmann
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.29.2006 at 10:12AM PDT, ID: 16785034

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.29.2006 at 11:49AM PDT, ID: 16785408

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2006 at 11:59AM PDT, ID: 16785441

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2006 at 12:01PM PDT, ID: 16785448

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2006 at 05:23PM PDT, ID: 16786597

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2006 at 05:27PM PDT, ID: 16786609

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2006 at 05:34PM PDT, ID: 16786629

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32