Line count of trace files for 24 period

Hi,
Using solaris 10 5.10 o/s
I am learning awk as I work here on the job.
What I need to do is isolate the trace file for the last 24 hours. After that I need to open those trace files and search for 'TNS-|ORA-' message from each one. These trace files MAY HAVE an occurance of them. I only need to recognize either one just once above before moving onto the next file otherwise it will become time consuming. The ultimate goal here is to do a total count (wc -l) for metric purposes. In other words if that line item includes the above it is to be counted.
So far this is what I got and would like to have some assistance or guidance as to how to complete this.

ls -l /oracle/diag/rdbms/*/*/trace/*d00*.trc | grep 'Jan 20' | awk '{print $9}'
output:
/oracle/diag/rdbms/abcdef/abcdef/trace/abcdef _d000_21750.trc
/oracle/diag/rdbms/abcdef/abcdef/trace/abcdef_d000_22001.trc
/oracle/diag/rdbms/abcdef/abcdef/trace/abcdef_d001_22002.trc

I generated the above list.
This is what I believe needs to happen next:
I need to loop thru this list, open each line using �more� or �cat� and do a "find" on 'TNS-|ORA-'. If it returns positive add it to the count.
count wc -l.

This part doesn�t work:

| awk 'BEGIN {more *.trc;} {egrep 'TNS-|ORA-' *.trc} END | wc �l

Any help or suggestions in this matter would be appreciated.
Thanks
al

Not the most efficient solution, but your code could probably use a rewrite from scratch. The ls -l is especially pointless and likely to break down.

ls -l /oracle/diag/rdbms/*/*/trace/*d00*.trc | grep 'Jan 20' | awk '{print $9}' | 
        xargs awk '/TNS-|ORA-/' | wc -l

Try this:

find /oracle/diag/rdbms/*/*/trace -type f -name '*d00*.trc' -mtime 0 -exec egrep -c 'ORA-|TNS-' '{}' '+'

Without further info I can tell you that this:

awk 'BEGIN {more *.trc;} {egrep 'TNS-|ORA-' *.trc} END | wc �l

cannot work. You have some logical and syntactical errors in there, e.g. a missing closing quote and awk and shell mixed up. awk does not know more or egrep , it needs a command or a script built from pattern {action} pairs. action is one or more awk commands, it cannot cope with shell commands.

That can be simplified to

ls -l /oracle/diag/rdbms/*/*/trace/*d00*.trc | awk '/Jan 20/ {print $9}' | 
        xargs egrep -c 'TNS-|ORA-'

Hi ,

Here is the final solution that works for me. I spent 3 hours learning about the syntax and making adjustments. This I am presently using at work.

find /oracle/diag/rdbms/*/*/trace -type f -name '*d00*.trc' -mtime 0 -exec egrep -c 'NS Primary Error' '{}' '+'

After reviewing the results I made an adjustment to the search string to 'NS PRIMARY ERROR' . This returned unique timestamps when the files were detailed indicating the total number of times the request was refused.

Thanks for your suggestions.

regards

al