Solved

Parse file to count specific records??

Posted on 2006-11-04
2
350 Views
Last Modified: 2009-12-16
In the file below I need to count how many records there are with the text: "MAXRUNALARM" or "JOBFAILURE" in the record. The pipe symbol is ithe record delimiter.

In this case there is a total of 13 records that meet the critieria.

sqlserv@ho|hol0127@isard|Fri Nov  3 02:14:20 2006|MAXRUNALARM|sqlservDBCpyRestoreDBVFNT
sqlserv@ho|hol0127@isard|Fri Nov  3 02:30:39 2006|CHASE|sqlservDBCpyRestoreDBVFNT
sqlserv@ho|hol0127@isard|Fri Nov  3 03:00:39 2006|CHASE|sqlservDBCpyRestoreDBVFNT
sqlserv@ho|ben1962@isard|Thu Nov  2 23:44:45 2006|MAXRUNALARM|sqlservEPHoldRestoreDBNT
stormgmt|tra3905@isard|Thu Nov  2 13:48:50 2006|JOBFAILURE|stormgmtCTMOperMartBkpBox
root|ben1962@isard|Fri Nov  3 06:15:19 2006|MAXRUNALARM|stormgmtNBUCancelNB
stormgmt|tra3905@isard|Thu Nov  2 13:52:04 2006|JOBFAILURE|stormgmtNBUInfoBox
udb|tra3905@isard|Thu Nov  2 13:49:04 2006|JOBFAILURE|stormgmtudbOnlineEbisdwpBkp1
udb|hol0127@isard|Fri Nov  3 01:48:23 2006|JOBFAILURE|stormgmtudbOnlineIpsamddpBkp
udb||Fri Nov  3 06:48:23 2006|MAXRUNALARM|stormgmtudbOnlineIpsconspBkp
udb|tra3905@isard|Thu Nov  2 13:18:58 2006|MAXRUNALARM|udbAuthCheckDanu04
udb|tra3905@isard|Thu Nov  2 13:15:51 2006|MAXRUNALARM|udbHeartbeatKubaz01
udb|tra3905@isard|Thu Nov  2 13:15:35 2006|MAXRUNALARM|udbHeartbeatTechno02
udb|str0264@isard|Thu Nov  2 12:53:48 2006|JOBFAILURE|udbHostInfoBox
udb|kel4693@yowza|Thu Nov  2 14:46:29 2006|MAXRUNALARM|udbHostInfoBox
udb|str0264@isard|Thu Nov  2 12:53:41 2006|STARTJOBFAIL|udbHostInfoBultar02
udb|str0264@isard|Thu Nov  2 12:53:42 2006|MAX_RETRYS|udbHostInfoBultar02

Thanks
0
Comment
Question by:rkckjk
2 Comments
 
LVL 6

Accepted Solution

by:
tone28 earned 500 total points
ID: 17873055
passing the file as an argument you can do this

while(<>) {
        $count++ if /(MAXRUNALARM|JOBFAILURE)/;
}

print $count;
0
 
LVL 2

Author Comment

by:rkckjk
ID: 17873167
Thanks
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question