Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to parse the log file to get useful information using perl or shell?

Reply
Thread Tools

How to parse the log file to get useful information using perl or shell?

 
 
robertchen117@gmail.com
Guest
Posts: n/a
 
      03-26-2007
hi all,

I have a very long log file like the below, how could I useful info I
need like this:

sr-204 Tec cache size:
"ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
total 1
-rw-rw-rw- 1 0 0 54 Nov 01 23:53
EventServer#opp1_0.dat

Also is get every 3 lines just after every "Tec cache size" including
the "Tec cache size" line.

Or even could I get just include the host name and file size? Like
this:
sr-204 54
sr-207 54
....

The log file like this:

.....
=================
sr-204.domain1.com:

DISSE0155I Distribution ID: `1278500431.264831'

------------------------------
STANDARD OUTPUT/ERROR BEGIN
------------------------------

STANDARD OUTPUT (program: c:\temp\check_itm_cache\check_itm_cache.bat
- exit code = 0)

sr-204 Tec cache size:
"ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
total 1
-rw-rw-rw- 1 0 0 54 Nov 01 23:53
EventServer#opp1_0.dat
""

------------------------------
STANDARD OUTPUT/ERROR END
------------------------------

=================

Software Package: "itm_cache^1.0"
Operation: install
Mode: not-transactional,not-undoable | force
Time: 2007-03-25 22:02:58
=================
sr-207.domain1.com:

DISSE0155I Distribution ID: `1278500431.264831'

------------------------------
STANDARD OUTPUT/ERROR BEGIN
------------------------------
STANDARD OUTPUT (program: c:\temp\check_itm_cache\check_itm_cache.bat
- exit code = 0)

sr-207 Tec cache size:
"ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
total 1
-rw-rw-rw- 1 0 0 54 Nov 01 23:58
EventServer#opp1_0.dat
""
.....

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      03-26-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:

> I have a very long log file like the below, how could I useful info I
> need like this:
>
> sr-204 Tec cache size:
> "ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
> total 1
> -rw-rw-rw- 1 0 0 54 Nov 01 23:53
> EventServer#opp1_0.dat



----------------------------------------------------
#!/usr/bin/perl
use warnings;
use strict;

local $/ = ''; # enable paragraph mode

while ( <DATA> ) {
next unless /Tec cache size/;
print;
}

__DATA__
=================
sr-204.domain1.com:

DISSE0155I Distribution ID: `1278500431.264831'

------------------------------
STANDARD OUTPUT/ERROR BEGIN
------------------------------

STANDARD OUTPUT (program: c:\temp\check_itm_cache\check_itm_cache.bat
- exit code = 0)

sr-204 Tec cache size:
"ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
total 1
-rw-rw-rw- 1 0 0 54 Nov 01 23:53
EventServer#opp1_0.dat
""

------------------------------
STANDARD OUTPUT/ERROR END
------------------------------

=================

Software Package: "itm_cache^1.0"
Operation: install
Mode: not-transactional,not-undoable | force
Time: 2007-03-25 22:02:58
=================
sr-207.domain1.com:

DISSE0155I Distribution ID: `1278500431.264831'

------------------------------
STANDARD OUTPUT/ERROR BEGIN
------------------------------
STANDARD OUTPUT (program: c:\temp\check_itm_cache\check_itm_cache.bat
- exit code = 0)

sr-207 Tec cache size:
"ls -l C:\Tivoli\lcf\dat\1\LCFNEW\Tmw2k\Tec\cache"
total 1
-rw-rw-rw- 1 0 0 54 Nov 01 23:58
EventServer#opp1_0.dat
""
----------------------------------------------------



--
Tad McClellan SGML consulting
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
useful setting in device manager (may be useful to know!) jameshanley39@yahoo.co.uk Computer Information 2 07-07-2008 04:28 PM
More Information than just IIS Log Information subrato ASP .Net 8 03-14-2006 09:59 PM
Urgent Pls: Facing problem in reading Log information from Log file, created by IIS Amratash ASP .Net 0 04-13-2004 09:08 AM
Help using regular expressions to parse complex log file. Max Adams Perl Misc 4 08-29-2003 12:22 PM



Advertisments