Solved

Parse file to count specific records??

Posted on 2006-11-04
2
348 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now