Solved

Parse file to count specific records??

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

11 Experts available now in Live!

Get 1:1 Help Now