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

R

robertchen117

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
""
.....
 
T

Tad McClellan

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
""
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top