?
Solved

Parse file to count specific records??

Posted on 2006-11-04
2
Medium Priority
?
360 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:Richard Kreidl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
tone28 earned 2000 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:Richard Kreidl
ID: 17873167
Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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.…
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…
Six Sigma Control Plans
Suggested Courses

771 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